执行中断,原因:试图取消引用无效的 ObjC 对象或向其发送无法识别的选择器



我遇到了以下问题。 将字符串帖子传递给 SecondVC.m

FirstVC.m
NSString *post = [[NSString alloc]initWithFormat:@"page=1&country=%@&state=%@&city=%@&empId=%@",_WSConstCountryID,_WSConstStateID,_WSConstStateID,_WSConstCityID,EmpId,@"0"];
NSLog(@"%@",post);
SecondVC *second = [self.storyboard instantiateViewControllerWithIdentifier:@"SecondVC"];
second.advstr = post;
//advstr is a string in SecondVC.m
[self presentViewController:second animated:YES completion:nil];

Error
reason: '-[UINavigationController setAdvstr:]: unrecognized selector sent to instance

when i degub and check
po second.advstr

错误:执行中断,原因:试图取消引用无效的 ObjC 对象或向其发送无法识别的选择器。进程已返回到表达式计算之前的状态。

正如错误消息所述,您正在尝试将 SecondVC 的属性设置为 UINavigationController 的实例。根据您的代码,这意味着情节提要包含一个标识符为"SecondVC"的UINavigationController,也许您有一个SecondVC控制器设置为其rootViewController

最新更新