我在传递对我的数据对象的引用时遇到问题。呈现视图控制器具有对数据对象的引用。模态视图控制器连接到导航控制器,并且是它的根视图控制器。这是我的做法:
介绍VC:
- (IBAction)changeCustomerButtonPress:(UIButton *)sender {
UINavigationController *customersNC = [self.storyboard instantiateViewControllerWithIdentifier:@"customersNC"];
SCCustomersVC *customersVC = (SCCustomersVC *)[self.storyboard instantiateViewControllerWithIdentifier:@"customersVC"];
customersVC.dataObject = self.splitVC.dataObject;
//at this point, customersVC.dataObject exists
[self presentViewController:customersNC animated:YES completion:nil];
}
当模态VC出现时,self.dataObject为nil。
- (void)viewWillAppear:(BOOL)animated
{
//self.dataObject is nil here.
}
这样做的正确方法是什么?