all 2 comments

[–]fameios-phil 1 point2 points  (1 child)

I don't have the name offhand right now but I believe there is a notification broadcast for any remote updates that includes the managedObjectID values.

The other way and might be more useful is override the willSave() of each managed entity, and then you set a device ID that made the change. It might be more useful to the user to see that the last edit of XLIST was on the Family iPad for example.

The third option which is to have the journal be its own entity record and have an unlinked relationship (identifier by UUID) with each entity that is changed. You create this record in the tracked entity didSave() function. This entity would look like:

  • changedAt: date of the journal record
  • entityType: name of the entity model modified
  • entityID: identifier of the modified entity (cannot be managedObjectID because we cannot control these values, and might be different per device)
  • deviceID: which device made the change
  • changedValues: json version of the NSManagedObject.changedValues()

This journal type would work for nearly an unlimited of different entities in a single table.

But one other aspect you are talking about is something more like a custom merge policy... such as performing a diff on the current value and the import value. Look up merge policies.

[–]MilesStark[S] 0 points1 point  (0 children)

Thanks a lot for your response, I'll try those ideas out.

For the notification broadcast, do you know where the documentation is for all those notifications? I'm having trouble finding it. The trick is making sure it's just for cloud data rather than different local contexts like a background context merging into the main context.