Change NSNumber value by allocating new NSNumber?
- by Peter Hajas
I understand that NSNumber is immutable, but I still have the need to change it in my app. I use it because it's an object, and therefore usable with @property (if I could, I would use float or CGFloat in a heartbeat, but sadly, I can't).
Is there any way to just overwrite the old NSNumber instance? I'm trying this:
NSNumber *zero = [[NSNumber alloc] initWithFloat:0.0];
myNSNumber = zero
but this doesn't change the value. This is a simplified version of my code, as I'm changing the root view controller's parameter (I know, not MVC-friendly). Still, the changing of the value should be the same assignment, right? Should I release myNSNumber first? What should I set the @property at for myNSNumber?
Thanks!