我的 Answers实体中有 syncState 布尔属性,该属性未映射。我使用 RkEntity Mapping 从服务器获取答案实体的记录。仅当的 syncState 已经存在时,我想保存/更新已经存在的记录$如果已存在的记录的syncState为未同步,则c $ c>记录将进行 Synced 并忽略从服务器获取的记录。 我正在考虑覆盖 Answers实体的 willSave 并忽略保存,但是该方法可用于更新一些记录,并避免避免保存托管对象。
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.
推荐答案您应使用 KVC验证,因为它允许您中止单个对象的映射,因此它们永远都不是保存对象,而不是尝试操作保存。特别是,您需要设置 discardsInvalidObjectsOnInsert 。
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.
更多推荐
仅当满足布尔条件,restkit尝试更新记录时才更新或保存托管对象
发布评论