I am trying to put a NSNumber to an array with this:
NSNumber *n = [NSNumber numberWithInt:1];
[[array objectAtIndex:0] setValue:n forKey:@"1"];
Then I have an action, which I want it to print the n.intValue from the array. I wrote it like this:
-(IBAction)action:(id)sender {
NSNumber *n = [[array objectAtIndex:0 ] valueForKey:@"1"];
NSLog(@"%d",n.intValue);
}
The problem is that it is printing 0 instead of 1.
How can I rewrite this to make it work?
Thanks.
You can simply do like this