<分区>
标签 ios objective-c segue
<分区>
这让我抓狂,因为我以前从未发生过这种事,而且我已经做过几十次了。
在两个 View Controller 之间传递一个值会导致该值为 NULL
。
我有一个 prepareForSegue:
方法:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString: @"LoginSegue"]) {
UITabBarController *destinationTabController = [segue destinationViewController];
ViewController *destinationViewController = destinationTabController.selectedViewController;
NSLog(@"Logged user is %@.", loggedUser); //This prints out the user correctly
destinationViewController.currentUser = loggedUser;
}
}
但是当执行 segue 时,我尝试记录 currentUser
值,它是 NULL
。
伙计们,有什么想法吗?
最佳答案
标签栏 Controller 不在界面中,因此未选择任何内容。因此 destinationViewController
是 nil
并且您尝试设置它的 currentUser
没有任何作用。
关于ios - 在 View Controller 之间传递时为空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38489052/