[英]how can I convert a nsnumber into a float
I need to multiply the value of an nsnumber by a float but they are of course incompatible types. 我需要将nsnumber的值乘以浮点数,但它们当然是不兼容的类型。 How can I cast the nsnumber to a float?
如何将nsnumber强制转换为浮点数?
float result = [myNSNumber floatValue] * myFloat;
请检查NSNumber类参考中的“访问数值”部分,以转换为其他类型。
像这样:
float value = [someNSNumber floatValue];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.