RestKit CoreData 0.20.3-映射完成后保存MOC之前的其他检查 [英] RestKit CoreData 0.20.3 - additional check before saving the MOC after mapping finished

查看:45
本文介绍了RestKit CoreData 0.20.3-映射完成后保存MOC之前的其他检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将其他检查添加到实体映射?我从服务器返回了一个具有相同标识属性的对象,我需要检查上次修改日期是否晚于我存储在本地商店中的对象.默认情况下,如果标识属性相同,RestKit将覆盖我的本地实例.映射是在子上下文上完成的,在将子上下文保存回父级之前,我试图比较服务器上的新值,但是我找不到任何简单的方法来拦截合并.有什么建议吗?

Is it any way to to add additional check to entity mapping? I have a returned object from the server with the same identification attribute and I need to check if last modified date is newer then my object stored in my local store. By default RestKit will overwrite my local instance if the identification attribute is the same. The mapping is done on a child context and I am trying to compare the new value from the server before the child context is saved back to parent but I can't find any easy way to intercept the merge. Any suggestion?

推荐答案

您应该考虑为此使用KVC验证,因为它将使您能够访问现有对象和新的传入值,并可以选择中止特定对象的映射.检查.

You should look at using KVC validation for this as it will give you access to the existing object and to the new incoming values and give you the option of aborting the mapping for that specific object. Check this.

这篇关于RestKit CoreData 0.20.3-映射完成后保存MOC之前的其他检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆