Adding an integer onto an array
- by Ohmnastrum
I'm trying to add random numbers onto the end of this array when ever I call
this function. I've narrowed it down to just this so far.
when ever I check to see if anything is in the array it says 0.
So now i'm quite stumped. I'm thinking that MutableArray releases the contents of it before I ever get to use them. problem is I don't know what to use. A button calls the function and pretty much everything else is taken care of its just this portion inside the function.
NSMutableArray * choices;
-(void) doSomething {
int r = arc4random() % 4;
//The problem...
[choices addObject:[NSNumber numberWithInt:r]];
int anInt = [[choices objectAtIndex:1] integerValue];
NSLog(@"%d", anInt);
//I'm getting nothing no matter what I do.
//some type of loop that goes through the array and displays each element
//after it gets added
}