Converting float to NSNumber Converting float to NSNumber ios ios

Converting float to NSNumber


The method floatValue of NSNumber does not take parameters. If you would like to set a new float number, you need to re-assign testNSNumber, because NSNumber does not have a mutable counterpart:

testNSNumber = @(myfloatvalue); // The new syntax

or

testNSNumber = [NSNumber numberWithFloat: myfloatvalue]; // The old syntax


Swift 3.0:

let testNSNumber: NSNumber = NSNumber(value: myfloatvalue)


Swift 2.0 version:

let testNSNumber: NSNumber = NSNumber(float: myfloatvalue)


matomo