iOS 检查远程服务器 plist 文件是否比本地存储的版本新?
我正在考虑使用 plist 来保存我的 iPhone 应用程序的一些数据,因为数据很小并且不需要任何过滤/排序等,plist 对我来说似乎是最简单的选择。
目前,每次启动应用程序时,我都会从网络服务器下载 plist,但是我只想下载比本地存储的 plist 文件更新的 plist。
目前我正在考虑执行以下操作,但想知道是否有更好的方法来执行此操作。
App Launch
Is Internet Available
remote_Version = Download MY_SERVER_URL\Version.txt
If local_version < remote_version
file = Download MY_SERVER_URL\data.plist
write plist to disk
end if
end if
谢谢亚伦
I'm looking at using a plist to hold some data for my iPhone Application, as the data is small and does not require any filtering / sorting etc the plist seems like the easiest option for me.
Currently I am downloading the plist from the web server each time the app is launched however I would like to only download the plist if it is newer than the locally stored plist file.
Current I thinking of doing the following but was wondering if there is a better way to do this.
App Launch
Is Internet Available
remote_Version = Download MY_SERVER_URL\Version.txt
If local_version < remote_version
file = Download MY_SERVER_URL\data.plist
write plist to disk
end if
end if
Thanks Aaron
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您能够从 Web 服务器更改文件的服务,我建议您查看 HTTP 状态代码。具体来说,如果文件尚未更新,您的网络服务器最好返回304 Not Modified。这消除了首先检查版本文件的需要。要正确执行此操作,您可以传递最后下载并随请求保存的文件的版本。
If you have the ability to change the serving of the file from the web server, I'd recommend you take a look at the HTTP status codes. Specifically, your web server would ideally return a 304 Not Modified if the file has not been updated. This removes the need to first check a version file. To do this correctly, you could pass the version of the last file downloaded and saved with the request.