我在我的目标c应用程序中使用JSONModel。我在第一个abBarController中获取所有数据给我的JSONModel。然后我需要在其他viewController中获取这些数据。我想这个数据发送给其他人viewControllers这样的:如何在不同的ViewControllers中使用JSONModel数据?
第一的ViewController:
@implementation FirstViewController
...
SecondViewController* infoController = [self.storyboard instantiateViewControllerWithIdentifier:@"secondViewController"];
SecondViewController.model = self.model;//Here send the model with data
[self.navigationController pushViewController:infoController animated:YES];
...
@end
第二的ViewController:
@interface SecondViewController :UIViewController{
MyModel *model;
}
@property MyModel *model;
有一个更好的形式保持这个数据模型实例化并从另一个viewController获取模型数据,而不将其发送到属性中?
创建模型类的共享对象和ID对象设置JSON对象,然后访问它在任何视图控制器。 –
使用单例设置或获取模型数据 –