Possible Duplicate:
Convert string to float in Objective-C
I'd like to convert a string to a float.
/* dict is an NSDictionary to load Preferences */
NSString *str = [dict objectForKey:@"key"];
This is where I got. Now I'd like to convert the string value (in this case @"32.0f"
) in a float, where it could be processed by my application. How can I do this?
CGFloat strFloat = (CGFloat)[str floatValue];
Just pass the message floatValue
to the NSString
object. NSString::floatValue
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