so I want to convert NSString
to double. I found the following example:
NSString * s = @\"1.5e5\";
NSLog(@\"%lf\", [s doubleValue]);
You can use the NSScanner
class:
NSString *s = @"1.5e5";
NSScanner *scanner = [NSScanner scannerWithString:s];
double d;
BOOL success = [scanner scanDouble:&d];
If you want to ensure that the entire string has been scanned (no extra characters after the number), use
BOOL isAtEnd = [scanner isAtEnd];