I have a mutable array that, originally, I was having trouble with the scope. I got some advice on how to fix that (which worked), but now the array will not replace the objects at a given index.
Here is the code:
.h file:
@interface myViewController: UIViewController {
NSMutableArray *myArray;
}
.m file:
-(id)init {
self = [super init];
if (self){
myArray = [[NSMutableArray alloc] init];
}
return self;
}
-(void)viewDidLoad {
for (int x=0; x<6; x++) {
[myArray addObject:[NSNumber numberWithInt:0]]; //This adds the numbers just fine
}
[myArray insertObject:[NSNumber numberWithInt:1] atIndex:0]; //This does not insert the number 1 into index 0
}
I've tried other ways to insert, such as:
replaceObjectAtIndex: withObject
And some others, but none of them worked....
I would greatly appreciate any help as this is the only thing standing between me and finishing my first app.
Thanks!