importing AppDelegate

后端 未结 7 1506
生来不讨喜
生来不讨喜 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:29

    You should seriously avoid importing the AppDelegate everywhere and you should feel like you are doing something wrong each time you do it (+1 for that). You are essentially creating a Big Ball of Mud and should reconsider your design. If for example you are using CoreData for your models consider a framework such as Magical Panda Active Record to retrieve data. I work on an enterprise application and the AppDelegate.h is only include in AppDelegate.m.

提交回复
热议问题