I try to write a game tag. According to the rules of the game with an empty cell, only adjacent cells can vary (vertically and horizontally).
The problem is that when using the condition of turning on or off the button itself, after starting the game it confuses the user considerably, since when doing actions, it turns out that the cells do not change places, but the cross (of the active buttons) moves across the field.
NSInteger point = 0; NSArray *arrCells = [self->myMatrix cells]; for (int i = 0; i < arrCells.count; i++) { [[self->myMatrix cells] objectAtIndex:i].enabled = false; ((NSButtonCell*)[arrCells objectAtIndex:i]).target = self; ((NSButtonCell*)[arrCells objectAtIndex:i]).action = @selector(btnClick:); if ([((NSButtonCell*)[arrCells objectAtIndex:i]).title isEqualToString:@""] == true) { point = i; } } if(point +1 <= 15) { ((NSButtonCell*)[arrCells objectAtIndex:point+1]).enabled = true; } if(point - 1 >= 0) { ((NSButtonCell*)[arrCells objectAtIndex:point-1]).enabled = true; } if(point - 4 >= 0) { ((NSButtonCell*)[arrCells objectAtIndex:point-4]).enabled = true; } if(point + 4 <= 15) { ((NSButtonCell*)[arrCells objectAtIndex:point+4]).enabled = true; } The question is - how to prohibit the action of a button without changing it visually.