I need to multiply the value of an nsnumber by a float but they are of course incompatible types. How can I cast the nsnumber to a float?
Asked
Active
Viewed 3.3k times
2 Answers
57
float result = [myNSNumber floatValue] * myFloat;
Please check the "Accessing Numeric Values" section from NSNumber class reference for converting to other types.
-
What if I put a double (like 1.0) into a NSNumber? – Pavel Alexeev Feb 13 '15 at 18:21
17
Like so:
float value = [someNSNumber floatValue];