开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜