Notifying the Application of Changes

Once we’ve made changes on disk, we need to notify the contexts of these changes.

In this particular example, doing so isn’t strictly necessary. Most likely the user interface hasn’t touched any of these objects yet. If the objects haven’t been loaded into memory, there’s no risk of a conflict. However, it’s best that we don’t assume they haven’t been loaded yet. Users can be very clever.

There are two basic ways to notify our NSManagedObjectContext instances of the changes. We can reset each object individually in each NSManagedObjectContext that it might be associated with, or we can use the new API that was added in iOS 9.0. Let’s look at the harder way first.

Manual Object Refreshing

If the situation ...

Get Core Data in Objective-C, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.