我使用我的 AppDelegate
作为模型来检测我的推送通知是否被点击 - 我的推送通知 ID 是什么,如果我的 View Controller 之一折叠(使用侧边栏),如果我的 TableViewCell 是选择(这会影响其他 View Controller )。我不太使用 AppDelegate
,通常使用模型。
@property (nonatomic, assign) NSInteger selectedRow;
@property (nonatomic, assign) BOOL isMenuCollapse;
@property (nonatomic, assign) BOOL notificationWasTapped;
@property (nonatomic, assign) long long pushNotificationId;
最佳答案
意见:我会将它们包装在一个不同的类中,这样,如果应用增长,您就已经为真正的模型分离做好了准备。
我认为模型类的实例可通过应用程序委托(delegate)使用没有问题,类似于委托(delegate)如何了解 View 层次结构的根。
关于iOS:使用你的 Appdelegate 作为小东西的模型是好的设计模式吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26506899/