What is the most efficient way to observe managed object context changes for specific entity types in iOS?

Sorry if this has been discussed to death elsewhere, but I couldn't find a question that directly addresses my request.

I am working on an application that downloads objects from a remote server in JSON format and converts the result to basic data objects.

I have used NSFetchedResultsController

for a while to observe changes to objects for certain types of entities when applying a filter NSPredicate

. The purpose here is to inform about changes only when managed objects that meet certain criteria have been added, changed, or removed.

I know NSManagedObjectContextObjectsDidChangeNotification

of NSManagedObjectContext

, however I understand that the dictionary -userInfo

contains all changes to objects, regardless of the entity.

My concerns may be unfounded, but since I am not using NSFetchedResultsController

for control UITableView

am I wastefully using a class for this purpose?

Is there a better way to notify me when objects of a particular object type and property values ​​have been added, changed, or removed?

Many thanks.

Ps I am aware of accessibility NSArrayController

in Cocoa, which appears to contain the required functionality, although I have not experimented with it. This class is not available for iOS.

+3


source to share


2 answers


I have used NSFetchedResultsController

in the past to track changes to Core Data objects that interest me. It says nothing that you have to bind it to the UITableView implementation.



However, you can look at this question: Using NSFetchedResultsController without UITableView

+2


source


NSManagedObjectContextObjectsDidChangeNotification

      

it provides notification whenever a managed object in the context is inserted / updated / deleted.



or

you can use subclass custom NSManagedObject

+3


source







All Articles