importing AppDelegate

后端 未结 7 1502
生来不讨喜
生来不讨喜 2020-12-05 18:43

Often times I initialize my model class variables in my AppDelegate so they can be used by different ViewControllers without passing their instance across class files. Howe

7条回答
  •  南方客
    南方客 (楼主)
    2020-12-05 19:32

    Put this method in your AppDelegate class

    + (AppDelegate *)get {
        return (AppDelegate *) [[UIApplication sharedApplication] delegate];
    }
    

    And when you need to call your AppDelegate use:

    [AppDelegate get];
    

提交回复
热议问题