将数据模型分配给appDelegate中带有故事板的视图控制器-ios

将数据模型分配给appDelegate中带有故事板的视图控制器-ios,ios,storyboard,uistoryboard,appdelegate,Ios,Storyboard,Uistoryboard,Appdelegate,没有情节串连板的情况下,我使用AppDelegate的didfishlaunchingwithoptions中的此代码将数据模型分配给视图控制器: //Data Model Class DataModel *model=[[DataModel alloc] init]; // TableViewController Controller *controller=[[Controller alloc] initWithModel:model style:UITableViewStylePlain

没有
情节串连板
的情况下,我使用
AppDelegate的
didfishlaunchingwithoptions
中的此代码将
数据模型
分配给
视图控制器

//Data Model Class
DataModel *model=[[DataModel alloc] init];

// TableViewController
Controller *controller=[[Controller alloc] initWithModel:model style:UITableViewStylePlain];

self.window.rootViewController=controller;
在查看控制器的
方法的initWithModel中:

-(id)initWithModel:(SBQAllReadersModel *) aModel
             style:(UITableViewStyle)    aStyle{

    if (self=[super initWithStyle:aStyle])
    {
        _model=aModel;
    }

    return self;
}
但是有了
情节提要
,我无法做到:

//Data Model Class
DataModel *model=[[DataModel alloc] init];

UIStoryboard *mainStoryboard = [UIStoryboardstoryboardWithName:@"MainStoryboard" bundle: nil];

Controller *controller = [mainStoryboard instantiateViewControllerWithIdentifier:@"Controller"];

controller.model=model;
问题是在
情节提要
中,我不能使用
视图控制器
init
方法,因为它不能被
情节提要
识别。我必须使用
initWithCoder:
,它不能被覆盖,并且我不能将参数传递给
awakeFromNib

您建议我如何从
appDelegate
将带有
情节提要的
数据模型
分配给
控制器


非常感谢您

考虑到数据模型的分配方式,我认为在first view控制器中使用惰性getter(甚至比您以前的方法)更为优越。e、 g


视图控制器的
initWithCoder
:中,我分配了模型

-(id)initWithCoder:(NSCoder *)aDecoder{
    if(self = [super initWithCoder:aDecoder])
    {
        // Do something
        _model=[[DataModel alloc] init];
    }
    return self;
}
是的,最好用你说的懒惰的人;)


因此,我必须在
rootViewControler
中分配
模型
,并通过
委托
将模型传递给需要使用它的下一个控制器吗

谢谢!!请看我的答案。
-(id)initWithCoder:(NSCoder *)aDecoder{
    if(self = [super initWithCoder:aDecoder])
    {
        // Do something
        _model=[[DataModel alloc] init];
    }
    return self;
}