iOS:RESTKit与CoreData同步数据 [英] iOS: RESTKit sync data with CoreData

查看:250
本文介绍了iOS:RESTKit与CoreData同步数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设置:
在后端使用MySQL数据库的RESTFull API。

Setup: RESTFull API with MySQL Database in the Backend.

我使用RESTKit v.20.3来进行API调用。

I'm using RESTKit v.20.3 to make the API calls. I'm about to switch to Core Data.

问题:

如果我在遥控器中有10个物件数据库,并且我第一次使用GET获取,我将获取所有10个对象并存储在Core Data本地。当我进行后续的获取请求时,如何告诉RESTKit只下载新对象,而不是下载它先前下载的相同的10个对象?最佳做法请!

If I have 10 objects in the remote database and I fetch for the first time using GET, I will get all 10 objects back and stored in Core Data locally. When I make subsequent fetch requests, how do I tell RESTKit to only download new objects only and not the same 10 objects that it downloaded earlier? Best practice approach please!

推荐答案

首先,使用最新版本的RestKit(检查github)。

First, use the latest version of RestKit (check github).

其次,这是一个关于服务器提供的Web服务的问题,而不是RestKit或您的客户端。通常,当您发出请求时,您应该存储创建日期,并且作为请求的一部分,您应该传递最后一个请求日期,以便服务器可以过滤以找到适当的数据返回。

Second, this is a question about the web service offered by the server, not RestKit or your client specifically. Generally, when you make a request you should store the date you made it, and as part of the request you should pass the last request date so the server can filter to find the appropriate data to return. Technically, you should only store the request date when you receive a valid response from the server...

这篇关于iOS:RESTKit与CoreData同步数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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