我正在代码中启动一个模态视图控制器,并希望传递一个数据对象。我在目标 VC 上为该对象创建了一个属性。新的 VC 启动正常,但没有获取数据对象。下面的代码有什么问题吗?如果不是,我将不得不在其他地方寻找错误,但想知道这是否是传递数据对象的正确方法。
//in header file of destination VC
@property (nonatomic, strong) Product *product;
//in .m file of starting VC
- (void) gotoStoryboard {
UIStoryboard *storyBoard = self.storyboard;
moreInfoVC *infoVC =
[storyBoard instantiateViewControllerWithIdentifier:@"moreInfo"];
infoVC.product = _product;//IS THIS ADEQUATE TO PASS DATA OBJECT?
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController: infoVC];
[self presentModalViewController:nav animated:YES];
}