我在代码中启动模态视图控制器,并希望传递数据对象。我已经在对象的目标VC上创建了一个属性。新的VC正在启动,但没有获取数据对象。下面的代码有什么问题吗?如果没有,我将不得不在其他地方寻找错误,但是想知道这是否是传递数据对象的正确方法。iOS/objective-c:将对象传递到新的视图控制器
//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];
}