问题
I have syncState boolean attribute in my Answers Entity which is not mapped. I get records of Answer Entity from server using RkEntity Mapping. I want to save/update already existing records only if syncState of already existing records is Synced and ignore records fetched from server if syncState of already existing records is UnSynced.
I was thinking of overriding willSave of Answers Entity and ignore saving but that method can be used to update some records and not avoid saving managed object.
回答1:
You should use KVC validation for this as it allows you to abort the mapping of individual objects so they are never candidates for saving rather than trying to manipulate the save. In particular, you need to set discardsInvalidObjectsOnInsert.
来源:https://stackoverflow.com/questions/18628451/update-or-save-managed-object-only-when-boolean-condition-is-met-when-restkit