开发者

Why an unsaved modified NSManagedObject returns FALSE on isUpdated after closing/opening app?

开发者 https://www.devze.com 2023-03-29 03:30 出处:网络
Why an unsaved but modified NSManagedObject has an empty -changedValues and returns FALSE on - isUpdated after closing/opening the app (running in background)?

Why an unsaved but modified NSManagedObject has an empty -changedValues and returns FALSE on - isUpdated after closing/opening the app (running in background)?

I don't want to save a modified NSManagedObject开发者_运维问答 on applicationDidEnterBackground, but I want to know whether it was updated after applicationWillEnterForeground.

In my implementation I get an empty [object changedValues] and FALSE [object isUpdated]

Is this normal? What could I do to not save an modified object, quit app, return and get the isUpdated TRUE?


In applicationDidEnterBackground simply check isUpdated and set a variable to the result. In applicationWillEnterForeground check your variable.

However, I do not think that is good practice. Why would you not want to save on entering background? Either you want to persist the change, then save it; or you don't, then throw it out.

Remember, once the app is in the background, there is no guarantee it will ever come back. So the rule is that you should persist everything you need in order to recreate it when the app becomes active again.

0

精彩评论

暂无评论...
验证码 换一张
取 消