h3dkandi h3dkandi - 1 year ago 71
Objective-C Question

What comes first applicationWillResignActive app delegate method or the Notification for the same event?

In my app delegate I save(persist) an object when the

method is called. I have a view controller which responds to
and makes a modification to the previously mentioned object but doesn't save(persist) the object itself.
What I need to know is if that change will be persisted trough the
method or if I should explicitly save it in the view controller just to be sure?

test result is: 1st is the delegate method, 2nd it is the Notification method.

I wasn't sure the test would guarantee me that the order will be the same every time because I don't know how notification center works. That is why I posted the question before testing and giving results.

Answer Source

The documentation for applicationWillResignActive: says, "After calling this method, the app also posts a UIApplicationWillResignActiveNotification notification to give interested objects a chance to respond to the transition."

The "after" makes me believe that you will not get the changed value inside applicationWillResignActive:.

Of course, inserting a couple of NSLog lines would let you prove the order of operation for yourself.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download