开发者

how can I convert a nsnumber into a float

开发者 https://www.devze.com 2023-02-14 01:51 出处:网络
I need to multiply the value of an nsnumber by a float but they are开发者_JAVA技巧 of course incompatible types. How can I cast the nsnumber to a float?float result = [myNSNumber floatValue] * myFloat

I need to multiply the value of an nsnumber by a float but they are开发者_JAVA技巧 of course incompatible types. How can I cast the nsnumber to a float?


float result = [myNSNumber floatValue] * myFloat;

Please check the "Accessing Numeric Values" section from NSNumber class reference for converting to other types.


Like so:

float value = [someNSNumber floatValue];
0

精彩评论

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