0

I have a web-based API that allows users to download data that has changed since the last time they downloaded data.

I only want to change the UpdatedOn date once Core Data is actually done updating. The parsing of this data occurs on a separate thread.

Since I save changes to my Entities as I cycle repeatedly through the data, so I do not want to change the UpdatedOn date until all changes are saved. Otherwise, any type of interruption in service would give the user incomplete data which could not be recovered without deleting records altogether.

Would this be best accomplished with Broadcast/Listener (not sure I am using right term here) sent/received when the parsing thread finishes executing?

2

1 Answer 1

0

Use a separate persistent store to write your changes as you work through them. Change your UpdatedOn if the entire update succeeds, and then move the new persistent store into the old persistent store's place.

Alternatively, do your updates in a child context, which you throw away without saving if your update fails.

2
  • Hal, would I still not need a NSNotificationCenter call to verify when either this persistent store or child context was completed? What would be the advantage of this over simply using NSNotification? Aug 10, 2014 at 14:45
  • Those are the same thing. You must use NSNotificationCenter to register for the NSNotification calls. Aug 10, 2014 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.