Search code examples
objective-ccachingcore-datansincrementalstore

Does NSIncrementalStoreNode updateWithValues's "values" argument require only the changed values or a complete new copy of the data?


I'm calling:

- (void)updateWithValues:(NSDictionary *)values
                 version:(uint64_t)version

in an NSIncrementalStore subclass in order to update the cache with update NSManagedObject values. My question concerns the values argument. Do I only need to put in the updated attributes or a complete new copy of the data?

The description in the documentation says: "Update the values and version to reflect new data being saved to or loaded from the external store. // The values dictionary is in the same format as the initializer."

It isn't clear to me whether or not the "values" that "reflect the new data" refers to only the updated attributes or all the attributes in the object.


Solution

  • It requires the complete data. I agree it wasn't very clear but I suppose the reason is so you can do the conflict handling first. The annoying thing is there is no way to get the values back from the node to merge in the new ones and set them again. Annoyingly this means you can't use the node as your cache object, I'm still learning the NSIncrementalStore so likely there reason for this design will come clear at some point.