Alex Rivera | Logout

How to convert a string to float?

Asked 2011-06-05T02:09:52.647
12

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?

Edit
Report

1 Answer

6

Just pass the message floatValue to the NSString object. NSString::floatValue

answered 2011-06-05T02:12:23.773

Your Answer