I want to make a simple Circle and Cross game.
I put 9 buttons but connected it to one method so when the user click any of them the title of the button change to X or O. All the buttons have different tags. Now I want to send the 'sender' to another method just to check if the user is Circle or Cross
-(void) show: (enum gamer) aGamer andSender: (id) sender
{
switch(aGamer)
{
case gCircle:
[sender setTitle:[NSString stringWithFormat:@"%c",'o']];
break;
case gCross:
[sender setTitle:[NSString stringWithFormat:@"%c",'x']];
break;
}
}
The problem is that the button does not change the title. Here is how I call the method show when I click the button.
[self show:aGamer andSender:sender];
You should be using setTitle:forState:
instead.
E.g.
[sender setTitle:@"o" forState:UIControlStateNormal]
Here is the link to the doc for UIButton: Link