问题
I am creating this question to make my last question to be more specific, here is my last question: IOS:CS193p fall2013 assignment2 task2:add a button to let user to restart the game
This is the specific error message I got: 2014-07-26 10:31:55.110 Matchismo[525:60b] -[CardGameViewController redealButton:]: unrecognized selector sent to instance 0x8c27590 2014-07-26 10:31:55.247 Matchismo[525:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CardGameViewController redealButton:]: unrecognized selector sent to instance 0x8c27590'
Here is the code I wrote in the button touching method, trying to "clear" the original object(memory) which is referenced by my two properties(game, theDeck), and reassign them with brand new objects in order to restart the game.
- (IBAction)touchReadealButton:(UIButton *)sender
{
self.theDeck = [[PlayingCardDeck alloc] init];
self.game = [[CardMatchingGame alloc]initWithCount:[self.cardButtons count] usingDeck:self.theDeck];
}
回答1:
My guess is that your button is hooked up to a IBAction
method that does not exist anymore. Check the xib/storyboard where your CardGameViewController
exists and check what the button is connected to. I'm guessing you renamed the method from redealButton
: to touchReadealButton
: at some point
来源:https://stackoverflow.com/questions/24966954/objective-c-property-reinitialization