Reputation: 107
I'm not entirely sure why I am getting this error. It occurs when I click the button on my FirstViewController:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FirstViewController 1ButtonPress:]: unrecognized selector sent to instance 0x10954bbd0'
My FirstViewController has a button (1ButtonPress) which performs a segue with another ViewController which has a embed NavigationController (so in my storyboard, the segue is from FirstViewController to the NavigationController). On this segue, some data is transferred to the other ViewController by:
First.m
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"abc"]) {
UINavigationController *navController = [segue destinationViewController];
SecondViewController *BVC = (SecondViewController *)(navController.topViewController);
BVC.BLLImg = [UIImage imageNamed:@"SomeImage.jpg"];
BVC.BLLTitle = @"SomeText";
}
}
The segue has the identifier "abc" in storyboard. Looking around it, I believe it has something to do with an incorrect class, but everything on first inspection looks fine.
Any other reason why I would be getting this error?
Upvotes: 3
Views: 6077
Reputation: 4168
Let's go through the error you saw. It says that an unrecognized selector was sent to an instance of FirstViewController
.
From what I deduce, you hooked up your button to your view controller, and removed the implementation from your view controller later, assuming that it'd remove the connection you earlier created from your button to your view controller. Unfortunately, that's not how it works. You need to remove the connection from the button too.
To do that, right click on your button in the storyboard, and remove the connection which says 1ButtonPress:
.
Side note: You're doing too much for a beginner to understand. Please try going through the Cocoa world step by step. Also, read up this article to learn about how to name your methods and variables in a more easy-to-understand way.
Upvotes: 7
Reputation: 66242
Right-click the 1ButtonPress
button in your Storyboard. Remove the action to 1ButtonPress:
.
Upvotes: 3