Hi,
I get EXC BAD ACCESS on the the first line in move: which mentions snakeArray, an NSMutableArray, I don't have a clue what's going on. Help much appreciated.
I get EXC BAD ACCESS on the the first line in move: which mentions snakeArray, an NSMutableArray, I don't have a clue what's going on. Help much appreciated.
Code:
//in header:
NSMutableArray *snakeArray;
//in imp.:
- (IBAction)start:(id)sender
{
NSLog(@"1");
snakeArray = [NSMutableArray arrayWithObject:[NSValue valueWithRect:NSMakeRect(truncf(gridSize*gridWidth/2)+gridSpacing/2, truncf(gridSize*gridHeight/2)+gridSpacing/2, squareSize, squareSize)]];
theTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(move:) userInfo:nil repeats:YES];
NSLog(@"2");
}
- (void)move:(NSTimer *)myTimer
{
NSLog(@"3%@", snakeArray); //happens here with the snake array, otherwise after "3" just below
//NSPoint lastSquare = [[snakeArray lastObject] rectValue].origin;
NSValue *lastSquare = [snakeArray lastObject];
NSLog(@"4");
NSPoint lastSquarePoint = [lastSquare rectValue].origin;