views:

183

answers:

2

Hi,

Is it possible to set multiple properties of an NSManagedObject and have the NSFetchedResultsController call controllerDidChangeContent: only once?

In other words, is it possible to say something like:

[managedObject beginChanges];
[managedObject setPropertyA:@"Foo"];
[managedObject setPropertyB:@"Bar"];
[managedObject commitChanges];

and then have the NSFetchedResultsController call controllerDidChangeContent: (and the other methods) only one time?

Thanks!

A: 

While definitely not a perfect solution, you could add a method to your managed object class that takes the two new property values, and works much like your code above.

Shaggy Frog
A: 

I'm solving it now by creating another NSManagedObjectContext, that acts as 'scratch pad' for the changes. Then when all edits have been done, it's merged back into the other context, using mergeChangesFromContextDidSaveNotification:. There is a sample project called CoreDataBooks showing how this works.

Martijn Thé