无法将数据设置为 prepareForSegue 中的数组
Can't set data to an array in prepareForSegue
我正在使用 Objective-C,我想为另一个视图控制器复制一个数组并推送它。这是我的代码:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"comment"]){
commentViewController *vc = segue.destinationViewController;
vc.comments = [[NSArray alloc]initWithArray:comments];
}
}
但是没用。我在 Xcode:
得到了这个
2015-12-06 16:27:45.802 net[1244:29117] -[UIViewController setComments:]: 无法识别的选择器发送到实例 0x7ff8d34eb720
2015-12-06 16:27:45.807 net[1244:29117] *** 由于未捕获的异常 'NSInvalidArgumentException' 而终止应用程序,原因:'-[UIViewController setComments:]: 无法识别的选择器发送到实例 0x7ff8d34eb720'
有人可以帮助我吗?
Select 故事板中的目标视图控制器。并在身份检查器中确保您的目的地 vc 是您的自定义 class,如图所示。
我正在使用 Objective-C,我想为另一个视图控制器复制一个数组并推送它。这是我的代码:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"comment"]){
commentViewController *vc = segue.destinationViewController;
vc.comments = [[NSArray alloc]initWithArray:comments];
}
}
但是没用。我在 Xcode:
得到了这个2015-12-06 16:27:45.802 net[1244:29117] -[UIViewController setComments:]: 无法识别的选择器发送到实例 0x7ff8d34eb720 2015-12-06 16:27:45.807 net[1244:29117] *** 由于未捕获的异常 'NSInvalidArgumentException' 而终止应用程序,原因:'-[UIViewController setComments:]: 无法识别的选择器发送到实例 0x7ff8d34eb720'
有人可以帮助我吗?
Select 故事板中的目标视图控制器。并在身份检查器中确保您的目的地 vc 是您的自定义 class,如图所示。