I have implemented a simple segue from a button click. Here is the view controller code:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
{
if (self.categoryInt == 1)
[segue.destinationViewController setCategoryKey:SD_ADDITION];
else if (self.categoryInt == 2)
[segue.destinationViewController setCategoryKey:SD_SUBTRACTION];
}}
- (IBAction)category1Selected:(id)sender {
self.categoryInt = 1;
[self performSegueWithIdentifier:@"ShowWorksheet" sender:self];}
From the log messages, I can see that it ran through the ViewDidLoad on the destinationviewcontroller completely but then it errors out
with: Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[MainMenuViewController categorySelected:]: unrecognized selector sent to instance 0x75360e0’
I have not implemented any specific selectors on these buttons. Also there is no “categorySelected” method in my MainMenuViewController. The method being invoked is “category1Selected”. What is causing this error?
I think you answered the question yourself. You are somehow sending “categorySelected” when you SHOULD be sending category1Selected.
Check to see if you previously wired a button to categorySelected in interface builder. If you had previously done this, but then changed the name of categorySelected to category1Selected in your code, interface builder would probably not update.