I have created the app with following code. Its working fine with iOS7 but it throws the below error when I run with iOS8.
[UINavigationController setGoalName:]: unrecognized selector sent to instance 0x7964e2c0
My firstViewcontroller.m
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
GoalDetailsViewController *goalsDetailsViewController = segue.destinationViewController;
NSLog(@"%@",[NSString stringWithFormat:@"%@", [[self.arrCategoryTitle objectAtIndex:indexPath.row] objectAtIndex:indexOfCategory]]);
goalsDetailsViewController.goalName = @"Exercise Daily";
}
My GoalDetailsViewController.h
@interface GoalDetailsViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic) NSString *goalName;
Thanks in advance.
Seems like your destinationviewcontroller is a subclass of UINAvigationController.
Try this:
The easiest way to handle this crash would be to simply make sure that the
destinationViewController
is of the type you're expecting before you attempt to set a property on it. Something like this:This change ensures that the
destinationViewController
is of kindGoalDetailsViewController
before treating it as such.