Q:

NSMutableArray not being saved

I'm trying to insert objects (NSNumbers) into an NSMutable array, but when I check it, the objectAtElement always returns 0.
NSNumber *indexNum = [NSNumber numberWithInt:indexInt];
[last100 insertObject:indexNum atIndex:prevCount];
NSLog(@"Entry #%d : %d", prevCount, (int)[last100 objectAtIndex:prevCount]);
prevCount++;

indexInt is coming in through the method, I already checked it and its valid. indexNum has also been checked and matches indexInt. The problem is NSLog(@"Entry #%d : %d", prevCount, (int)[last100 objectAtIndex:prevCount]); which always returns
2012-01-08 14:08:11.551 ThoughtSpreader[20746:fb03] Entry #9 : 0 The entry number will change, but the 0 is always there. 
Oh, I also checked [last100 count] after every time I insert something new into it, and it always returns 0, so I believe its a problem with how I'm inserting something into the NSMutable array

A:

If your count always returns 0 the likelihood is you haven't actually instantiated your NSMutableArray.
NSMutableArray *array = [NSMutableArray array];

[array addObject:[NSNumber numberWithInt:1]];

NSLog(@"%lu", [array count]); // Count => 1

//-------

array = nil;

[array addObject:[NSNumber numberWithInt:1]]; // Calling methods on nil is a no-op

NSLog(@"%lu", [array count]); // Count => 0

Updated %d to %lu thanks to @markhunte - it's hard to remember the finer details without testing it

