2 Replies
      Latest reply on May 30, 2019 7:24 AM by tonycz
      tonycz Level 1 Level 1 (10 points)

        I'm trying to use Persistent History Tracking to implement data synchronization with the server. The idea is that for every NSPersistentHistoryTransaction, I want to (eventually) make analogous REST requests to perform identical change on the server.

        My code iterates through all the changes in the transaction. When the change is a DELETE, I can't figure out, how to tell what object type was deleted. As far as I can tell, the only thing I've got is the tombstone - which are some of the original object's fields (externalId in my case). While ID is an identifier, I also need to know what entity that ID belongs to.


        The documentation for the whole Core Data feature is next to none :-/


        The only solution I could come up with is to add a new field to each entity. The field name is entityType, type is String and the default value is whatever the entity is. And I set the "Preserve After Deletion" for this field.

        This does solve the the problem. The drawback is that I store few extra bytes for every record I save.


        If anyone can think of a better solution, I'd love to see it.