Update or save managed object only when boolean condition is met , when restkit tries to update records

廉价感情. 提交于 2019-12-13 04:35:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!