哪个 xcode 应用程序用于预填充数据库 [英] which xcode application for pre filling a database

查看:25
本文介绍了哪个 xcode 应用程序用于预填充数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还在学习xcode和objective-c.我仅用于为 iphone 环境构建应用程序.但是,我需要使用现有的预填充 sql 数据库来实现应用程序.

I am still learning xcode and objective-c. I use to build app for iphone environment only. However I am in need of realizing an application with an existing prefilled sql database.

为了预填充数据库,我不想在分布式应用程序中使用代码,但我更愿意使用单独的应用程序来执行此操作.

For prefilling the database I wouldn't like to use code in the ditributed app, but I would rather prefer to have a separate app for doing that.

原因是,应用程序只能下载更新的数据库,而不是整个代码更新.

The reason is that, the app could only download the updated database, rather than a whole code update .

所以,问题是:

  1. 这是一种可能的情况吗
  2. 如果是,什么样的申请我应该在 xcode 中构建预填充数据库?

谢谢

推荐答案

您没有理由不能拥有一个既使用数据库又下载更新的应用程序.在不下载整个内容的情况下保持数据库更新非常简单.

There's no reason that you can't have one app that both uses the database and downloads updates. Keeping the database updated without downloading the whole thing is pretty simple.

如果您在服务器上记录数据库中行的创建和修改时间戳,并在设备上跟踪这些相同的修改时间戳,则更新数据库的工作方式如下:

If you record the creation and modification timestamps of rows in the database on the server and keep track of those same modification timestamps on the device, updating the database works like this:

  1. 设备确定给定表的最新修改时间戳.我们将其称为latestTimestamp.它将latestTimestamp发送到服务器.

服务器将 latestTimestamp 与数据库中的创建和修改时间戳进行比较.服务器根据比较结果发回数据:

The server compares the latestTimestamp to the creation and modification timestamps in the database. The server sends back data based on the comparison result:

  • 如果修改时间戳早于latestTimestamp,则不需要发送记录,设备已经有了;

  • If the modification timestamp is earlier than latestTimestamp it doesn't need to send the record, the device already has it;

如果修改时间戳晚于latestTimestamp并且创建时间戳早于latestTimestamp,它将记录发回,指出它要在设备数据库中更新

If the modification timestamp is later than latestTimestamp and the creation timestamp is earlier than latestTimestamp, it sends the record back noting that it is to be updated in the device database;

如果修改时间戳迟于latestTimestamp并且创建时间戳迟于latestTimestamp,它会发回记录,指出它要添加到设备数据库中.

If the modification timestamp is later than latestTimestamp and the creation timestamp is later than latestTimestamp, it sends the record back noting that it is to be added in the device database.

最后,服务器数据库需要跟踪已删除的记录和记录的每条记录的删除时间戳.如果latestTimestamp迟于删除时间戳,它会发回记录需要删除.

Lastly, the server database needs to keep track of deleted records and a deletion timestamp for every record recorded. If latestTimestamp is later than the deletion timestamp, it sends back that the record needs to be deleted.

显然,当您有各种连接的表时,它会变得有点复杂,但只要以正确的顺序发回,它就可以很好地工作.

Obviously it gets a bit more complicated when you have a variety of connected tables, but as long as things are sent back in the correct order, it works great.

使用异步数据请求(ASIHTTPRequest 库使它变得轻而易举)并更新用户使用应用程序时的背景.如果必须在与数据交互之前更新数据,您可以显示活动指示器并让用户等待.

Use asynchronous data requests (the ASIHTTPRequest library makes it a breeze) and update the data in the background while the user uses the app. If it's essential that the data be updated prior to any interaction with it you can display an activity indicator and have the user wait.

完全不需要单独的应用程序.

No need at all for a separate app.

这篇关于哪个 xcode 应用程序用于预填充数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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