开发者

How to convert a string to float? [duplicate]

This question already has answers here: Closed 11 years ago.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜