Fogmeister
Fogmeister

Reputation: 77641

NSFetchedResultsController change tracking

I know that an NSFetchedResultsController tracks changes from a bg context (i.e. merge changes).

Does it also track changes to the main context?

i.e. if I have an NSFetchedResultsController fetching Person objects and I use an "Edit Person" view to change the actual Person that is passed in will the Controller see the change?

Upvotes: 0

Views: 374

Answers (1)

Martin R
Martin R

Reputation: 539815

A fetched results controller tracks only changes from its own context. If you save changes on a background context and then merge the changes to the main context, the FRC on the main context will see these changes (normally, see below). But saying that it "tracks changes from a bg context" is misleading.

Whether the FRC sees non-persistent changes, depends on the setting of includesPendingChanges in the fetch request. By default, this value is YES, unless you set the value of resultType to NSDictionaryResultType. In that case, the FRC returns only the state of the persistent store, and change tracking does not work at all.

Upvotes: 1

Related Questions