allTiles is an NSMutuableArray declared with a capacity of 9. Next a loop inserts 9 NSNull objects with a method called resetArray
. I have a method called addToArray which accepts an NSNumber and index at which to insert the value at.
In another class I have int currentTileValue = [self getTileValue];
which returns a tile value. This value will be both the number into the array as well as the index. Whenever I attempt to add to the array it crashes with no indication of why.
allTiles = [[NSMutableArray alloc] initWithCapacity:9];
[self resetArray:allTiles];
- (void) resetArray:(NSMutableArray*) array {
for (int i = 0; i < 9; i++) {
[array insertObject:[NSNull null] atIndex:i];
}
}
- (void) addToArray:(NSNumber*)value :(int)index {
[allTiles insertObject: value atIndex:index];
}
//Different class
//Here is where I am trying to insert into the array.
[(BoxView *)self.superview addToArray:(NSNumber*)currentTileValue :currentTileValue];
What would be causing this to crash?