[UINavigationController setGoalName:]:无法识别的选择器发送到实例0x7964e2c0

Bal*_*yal 5 iphone ios7 ios8

我用以下代码创建了应用程序.它与iOS7配合使用,但是当我使用iOS8运行时它会抛出以下错误.

[UINavigationController setGoalName:]: unrecognized selector sent to instance 0x7964e2c0
Run Code Online (Sandbox Code Playgroud)

我的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";

}
Run Code Online (Sandbox Code Playgroud)

我的GoalDetailsViewController.h

@interface GoalDetailsViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic) NSString *goalName;
Run Code Online (Sandbox Code Playgroud)

提前致谢.

gas*_*uff 10

好像你的destinationviewcontroller是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";

}
Run Code Online (Sandbox Code Playgroud)