Adding Integer To NSMutableArray
arrays, nsnumber, object, objective-c
Solution
`NSMutableArray` doesn't take primitive types.
The second option is correct.
Problem
I couldn't find this anywhere, so I am asking just asking to make sure. And yes, I know its basic, but I figure I'd rather get that right before I make the mistake a million times: If I do the following, does it cast the "0" to an NSNumber by default (if not, what Object type is it), or would I have to do the 2nd code? (Or both of these could be wrong for what I'm trying to do. If so, let me know. They both compile so I am just wondering which one is "right" (or preferred) and why.) Code 1: ``` NSMutableArray array = [[[NSMutableArray alloc] init]]; [array addObject: 0]; ``` Code 2: ``` NSMutableArray array = [[NSMutableArray alloc] init]; [array addObject: [NSNumber numberWithInt: 0]]; ```