I'm not even sure, for example, if I can use it like a normal variable. There doesn't appear to be a mutable version. And does mutable mean it's value can be changed?
What do you mean by "full example usage"? Can you give a context for the kind of example you're looking for?
What do you mean by using something as a "normal" variable?
You can get an NSNumber
either by using the numberWithXXX
functions, which returns an autoreleased object, or by doing the standard alloc
/init
:
NSNumber* myAllocedNumber = [[NSNumber alloc] initWithFloat:0.0f];
// ...use it...
[myAllocedNumber release];
NSNumber* myAutoreleasedNumber = [NSNumber numberWithFloat:0.0f];
You can later change where your pointer is pointing to, but you can't change the value:
NSNumber* myAutoreleasedNumber = nil;
myAutoreleasedNumber = [NSNumber numberWithFloat:0.0f];
// ...use it...
myAutoreleasedNumber = [NSNumber numberWithInt:1000];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With