Objective-c property reinitialization

好久不见. 提交于 2019-12-12 04:07:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!