« first day (2654 days earlier)      last day (1329 days later) » 

09:49
Hello guys
in ios how to format a numeric textfield while entering text with 1,234,567,890
 
1 hour later…
10:55
@Shubhank
@Shubhank
@Priya
yes
@RobinHood
how to format a numeric textfield while entering/removing text with 1,234,567,890
haan
Hw r u sir
@Shubhank: I tried below code. But not formmatting correctly.

#define NUMBERS_ONLY @"1234567890"
#define CHARACTER_LIMIT 13
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
NSUInteger newLength = [textField.text length] + [string length] - range.length;
NSCharacterSet *cs = [[NSCharacterSet characterSetWithCharactersInString:NUMBERS_ONLY] invertedSet];
NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
11:40
let me check
@Priya
you want to have 13 numbers only?
12:20
yes
@Shubhank
@Shubhank: Actually 10digits only including comma it should be 13 characters
12:45
means
?
is the length wrong or the comma is the issue?
13:20
comma is the issue
while entering i need to add comma, by deleting i need to remove
13:36
@Shubhank
can u check once
@Shubhank Hi. How are You?
I thought - this room was closed... nobody came online...
14:17
hi
am fine @RipaSaha
yup - forgot in covid.. my laptop was not working for some time
@Priya okay, what happens currently
Comma not working properly with above code
@Shubhank
@Shubhank: What is the best way i can achieve like 1,234,567,890
have a utility method
which converts a string and adds comma
call that from - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
}
@Shubhank: What is the utility method?
14:37
@Shubhank ok
How's Your work going on?
15:17
@Priya any common functions you have
currently you have it in your code like getStringFormmatedByComma
I have below function:

- (NSString *)getStringFormmatedByComma:(NSString *)strAmount {
//Add Comma to Number
NSNumberFormatter *formatter = [NSNumberFormatter new];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle]; // this line is important!
NSString *formattedText = [formatter stringFromNumber:[NSNumber numberWithInteger:[strAmount integerValue]]];
return formattedText;
}
why comma is giving issue in it
what happens
@RipaSaha going good
you tell
while entering comma is not coming
properly
but separately if use utility method working fine
in TextFieldshould charachers in range that utility method not working properly
but separately if use utility method working fine
Can you try once
15:53
i can't try objc code now @Priya
can you send me a small proj with it
i will try

« first day (2654 days earlier)      last day (1329 days later) »