将在线内容与 iPhone 应用程序同步
我正在寻找某种方法将在线 XML 文件与我的 iPhone 应用程序同步,并且仅下载最新更改的项目。每个项目都标记有日期属性,所以我认为这是可能的。我听说 Core Data 可以完成这项任务,但我不确定建议的方法以及如何实现它。
感谢您的任何帮助。
I am looking for some way to sync a online XML file with my iPhone application and only download the newest changed items. Each item is marked with a date attribute, so I assume this is possible. I have heard that Core Data can accomplish this task, but I am unsure of the suggested method and how to approach implementing it.
Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Apple 确实有同步服务框架,但目前在 iPhone SDK 中不可用。
我目前实际上也在做类似的事情。同步并不像您首先想象的那么简单。就使用 Core Data 执行此操作而言,您希望在单独的托管对象上下文中执行同步,保存该上下文,并处理保存通知以将其合并到主上下文中,以便您的应用程序接收所有正确的更改事件。
您还需要处理服务器/客户端具有不同系统时间的情况。即使是几秒钟的差异也可能会导致问题,具体取决于您合并更改的方式。
Apple does have a Sync Services framework but it isn't currently available in the iPhone SDK.
I'm actually doing a similar thing currently. Syncing isn't as trivial as you might first think. As far as doing this with Core Data goes, you want to perform the sync in a separate managed object context, save that context, and handle the save notification to merge it into your main context so that your application receives all the correct change events.
You need to handle when the server/client has a different system time as well. Even a difference of a few seconds can cause problems depending on how you are merging the changes.