applicationWillResignActive app delegate 方法或同一事件的 Notification 首先出现的是什么?
What comes first applicationWillResignActive app delegate method or the Notification for the same event?
在我的应用程序委托中,我在 applicationWillResignActive:
方法被调用时保存(持久化)了一个对象。我有一个视图控制器响应 UIApplicationWillResignActiveNotification
并对前面提到的对象进行修改但不保存(持久化)对象本身。
我需要知道的是,该更改是否会通过 applicationWillResignActive:
方法保留,或者我是否应该明确地将其保存在视图控制器中以确保安全?
编辑: NSLog
测试结果是:第一个是委托方法,第二个是通知方法。
我不确定测试能否保证每次的顺序都相同,因为我不知道通知中心是如何工作的。这就是为什么我在测试和给出结果之前发布问题。
applicationWillResignActive:
的文档说,"After calling this method, the app also posts a UIApplicationWillResignActiveNotification notification to give interested objects a chance to respond to the transition."
"after" 让我相信你不会在 applicationWillResignActive:
中得到改变的值。
当然,插入几行NSLog
就可以让你自己证明操作顺序。
在我的应用程序委托中,我在 applicationWillResignActive:
方法被调用时保存(持久化)了一个对象。我有一个视图控制器响应 UIApplicationWillResignActiveNotification
并对前面提到的对象进行修改但不保存(持久化)对象本身。
我需要知道的是,该更改是否会通过 applicationWillResignActive:
方法保留,或者我是否应该明确地将其保存在视图控制器中以确保安全?
编辑: NSLog
测试结果是:第一个是委托方法,第二个是通知方法。
我不确定测试能否保证每次的顺序都相同,因为我不知道通知中心是如何工作的。这就是为什么我在测试和给出结果之前发布问题。
applicationWillResignActive:
的文档说,"After calling this method, the app also posts a UIApplicationWillResignActiveNotification notification to give interested objects a chance to respond to the transition."
"after" 让我相信你不会在 applicationWillResignActive:
中得到改变的值。
当然,插入几行NSLog
就可以让你自己证明操作顺序。