Quote:
Originally Posted by mindus
Hi
NSNumber start;
start = [NSNumber numberWithInt  [start intValue] + 5)];
i can able to increment up to three times (start = 16). After that if i try to increase this, i am getting Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UILabel intValue]: unrecognized selector sent to instance 0x392be00'
exception
anybody know how to solve this
Thanks
mindus
|
The other poster told you what was wrong with your code. You need to retain the NSNumber you are creating, and release the old one before you replace it.
This would be a perfect application for using a retained property.
If you declare start as a retained property in your header, like this:
Code:
@property (nonatomic, retain) NSNumber* start;
and in the body of your class, synthesize it like this:
Then your code can read like this:
Code:
self.start = [NSNumber numberWithInt:([start intValue] + 5)];
Note that we are saving a value to start using property notation (self.start). That causes the code to call the setter for the start property, which retains the new value and releases the old value.