繁体   English   中英

无法在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'

有人可以帮我吗?

在情节提要中选择目标视图控制器。 并且在身份检查器中,确保您的目标vc是您的自定义类,如图所示。

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM