Bronze Challenge:Unrecognized selector sent to instance


I am currently working on the Bronze Challenge. I added the files from the Quiz project, then added the QuizViewController to the TabController as shown:

    BNRHypnosisViewController *hvc = [[BNRHypnosisViewController alloc] init];
    BNRReminderViewController *rvc = [[BNRReminderViewController alloc] init];
    BNRQuizViewController *qvc = [[BNRQuizViewController alloc] init];
    UITabBarController *tabBarController = [[UITabBarController alloc] init];
    tabBarController.viewControllers = @[hvc,rvc, qvc];

When I go to the Quiz tab, the view loads. When I click Show Question, I get this error: -[BNRQuizViewController showQuestionButtonPressed:]: unrecognized selector sent to instance 0x8e6a810
2014-09-01 22:45:38.389 HypnoNerd[26459:60b] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[BNRQuizViewController showQuestionButtonPressed:]: unrecognized selector sent to instance 0x8e6a810’

I am not too sure what to do, all the connections in the Quiz files are correct.


The code you provided looks fine.

Can you show the code for showQuestionButtonPressed:, the method in the error msg?


Here is the code from showQuestionButtonPressed:

[code]- (IBAction)showQuestionButtonPressed:(UIButton *)sender
// Step to the next question

// Am I pas the last question?
if (self.currentQuestionIndex == [self.questions count]) {

    // Go back to the first question
    self.currentQuestionIndex = 0;

// Get the string at the index in the questions array
NSString *question = self.questions[self.currentQuestionIndex];

// Display the string in the question label
self.questionLabel.text = question;

// Reset the answer label
self.answerLabel.text = @"???";



Nevermind, I solved it. I added self.tabBarItem.title = @“Quiz”; to the Quiz class and it seems to work now. Very bizarre, I have no idea why that would cause an error.


Doesn’t make sense to me either, but glad you got it working.