I've got this little problem. When I have a string "3 568 030" and I use [myString intValue]; it gives me result just 3, the problem is I want to convert the whole number into int/nsinteger. The string always contains just the number if that's any help. I tried using replaceoccurencesofstring (or what is the name) and it somehow didn't work...
Thanks
Do:
NSString *str = @"3 568 030";
int aValue = [[str stringByReplacingOccurrencesOfString:@" " withString:@""] intValue];
NSLog(@"%d", aValue);
output
3568030
That is because of the spaces on your string you will have to remove the whitespaces first like this:
NSString *trimmedString = [myString stringByReplacingOccurrencesOfString:@" " withString:@""];
NSInteger *value = [trimmedString intValue];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With