Consider a managed object with a set of properties A which have to be replaced with a set of properties B. However, the mechanism to retrieve the information for B is not fail-safe (e.g. if there is a failing network connection) and there is a chance that B cannot be fully constructed. In this case, I need to fall back to the state of object A to maintain consistency.
What is the best Core Data pattern to realize a fail safe, consistent update mechanism in this case?
Consider a managed object with a set of properties A which have to be
Share
Until you send the
save:selector to theNSManagedObjectContextobject, none of your changes are persisted. Once ‘saved’ you have created a ‘commit point’. If you want to roll back any changes you have made since the last commit point in core data send therollbackselector to yourNSManagedObjectContext. You will need to check for successful outcome of your network activity and send eithersave:orrollbackdepending on the final outcome.