[UINavigationController setGoalName:]:无法识别的选择器发送到实例0x7964e2c0
问题描述:
我使用以下代码创建了应用。它与iOS7配合使用,但是当我使用iOS8运行时它会抛出以下错误。
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
我的firstViewcontroller.m
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";
}
我的GoalDetailsViewController.h
My GoalDetailsViewController.h
@interface GoalDetailsViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic) NSString *goalName;
提前致谢。
答
好像你的destinationviewcontroller是UINAvigationController的子类。
Seems like your destinationviewcontroller is a subclass of UINAvigationController.
试试这个:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
GoalDetailsViewController *goalsDetailsViewController = [(UINavigationController*)segue.destinationViewController topViewController];
NSLog(@"%@",[NSString stringWithFormat:@"%@", [[self.arrCategoryTitle objectAtIndex:indexPath.row] objectAtIndex:indexOfCategory]]);
goalsDetailsViewController.goalName = @"Exercise Daily";
}