0
votes

Objective C gives me a run-time error for the indicated line of code

-(void) play: (int)i at: (int)j {
    if ([self.board[i][j] isEqualToString:@""]){
        if (xplays) {
            self.board[i][j] = @"x";   //<-----HERE
        }
        else
            self.board[i][j] = @"x";
    }
    xplays = !xplays;
}

board is a property. The error message is

[__NSArrayI replaceObjectAtIndex:withObject:]: unrecognized selector sent to instance 0x7123120

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI replaceObjectAtIndex:withObject:]: unrecognized selector sent to instance 0x7123120'

Do I need to use C-arrays for this kind of assignment?

1

1 Answers

3
votes

You should be using an NSMutableArray.