Just like the title : how can i change a string @"$123.4" into a float value 123.4 in iOS
NSString *string = @"$123.4";
Any help will be appreciated. Thanks in advance.
Giki
Just like the title : how can i change a string @"$123.4" into a float value 123.4 in iOS
NSString *string = @"$123.4";
Any help will be appreciated. Thanks in advance.
Giki
@H2CO3 smart answer but i tried this last.
NSNumberFormatter * formatter = [[NSNumberFormatter alloc] init];
formatter.numberStyle = NSNumberFormatterCurrencyStyle;
formatter.currencyCode = @"USD";
float value = [[formatter numberFromString: @"$123.45"] floatValue];
NSLog(@"%f",value);
As seen with @H2C03
float price = [[string substringFromIndex:1] floatValue];
Hope this helps!