如何将字符串转换为float? [英] How to convert a string to float?
本文介绍了如何将字符串转换为float?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将一个字符串转换为浮点。
I'd like to convert a string to a float.
/* dict is an NSDictionary to load Preferences */
NSString *str = [dict objectForKey:@"key"];
这是我得到的。现在我想在一个float中转换字符串值(在这种情况下 @32.0f
),它可以由我的应用程序处理。如何做到这一点?
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];
这篇关于如何将字符串转换为float?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文