私は目的のCアプリケーションでJSONModelを使用しています。最初のabBarControllerでJSONModelにすべてのデータを取得します。次に、他のviewControllerでこのデータを取得する必要があります。別のViewControllerで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;
これを維持するためのより良いフォームがあります私のような他の人のviewControllersにこのデータを送信しようとしていますデータモデルはインスタンス化され、プロパティでこれを送信せずに別のviewControllerからモデルデータを取得しますか?
は、あなたのモデルクラスで共有オブジェクトを作成し、IDのオブジェクトにJSONオブジェクトを設定...このオブジェクトクラスのアクセス権を持っていることがあり、その後の任意のViewControllerでアクセス。 –
シングルトンを使用してモデルデータを設定または取得する –