简体   繁体   English

推出iPhone应用程序时如何保存初始数据?

[英]how can I hold initial data when introducing an iPhone app?

I am developing an iPhone app which retrieves information via NSUrlRequest and displays through UIWebView. 我正在开发一个iPhone应用程序,该应用程序通过NSUrlRequest检索信息并通过UIWebView显示。

I want to hold initial data (such as HTML pages, images) as a cache so that users of my app can access to data without network costs at the first time. 我想保留初始数据(例如HTML页面,图像)作为缓存,以便我的应用程序用户可以在第一时间访问数据而无需支付网络费用。 Then, if data on my web server are updated, I would download them and update the cache. 然后,如果更新了我的Web服务器上的数据,我将下载它们并更新缓存。 For performance issues, I think it is better to store data on file system than on core data. 对于性能问题,我认为将数据存储在文件系统上比存储在核心数据上更好。 Yet, I think it's not possible to release a new app writing data on disk. 但是,我认为不可能发布一个新的将数据写入磁盘的应用程序。

So, I am about to store initial data(or initial cache) at Core Data, and when users launch my app for the first time, I would copy the data to disk (like /Library folder). 因此,我将在Core Data中存储初始数据(或初始缓存),当用户首次启动我的应用程序时,我会将数据复制到磁盘(如/ Library文件夹)。

Is it, do you think, a good approach? 您认为这是个好方法吗? Or,...hmm, can I access to Core Data using NSUrlRequest? 或者,...嗯,我可以使用NSUrlRequest访问Core Data吗?

One more question, I might access to file system using NSURL, which is the same as to data on the Web. 还有一个问题,我可能会使用NSURL访问文件系统,这与Web上的数据相同。 (right?) My app would compare version of the cache with version of data on my web server, and if it's old, retrieve new data. (对吗?)我的应用程序会将缓存的版本与Web服务器上的数据版本进行比较,如果过旧,则检索新数据。 and my app will access only to file system. 而且我的应用只能访问文件系统。 All data are actually HTML pages including script, and images. 所有数据实际上都是HTML页面,包括脚本和图像。 And, I want to cache them. 而且,我想缓存它们。

could you suggest a better design? 你能建议一个更好的设计吗?

Thank you. 谢谢。

Is it, do you think, a good approach? 您认为这是个好方法吗? Or,...hmm, can I access to Core Data using NSUrlRequest? 或者,...嗯,我可以使用NSUrlRequest访问Core Data吗?

No. 没有。

One more question, I might access to file system using NSURL, which is the same as to data on the Web. 还有一个问题,我可能会使用NSURL访问文件系统,这与Web上的数据相同。 (right?) My app would compare version of the cache with version of data on my web server, and if it's old, retrieve new data. (对吗?)我的应用程序会将缓存的版本与Web服务器上的数据版本进行比较,如果过旧,则检索新数据。 and my app will access only to file system. 而且我的应用只能访问文件系统。 All data are actually HTML pages including script, and images. 所有数据实际上都是HTML页面,包括脚本和图像。 And, I want to cache them. 而且,我想缓存它们。

Yes. 是。

But you could also be more clever. 但是您也可以更聪明。 And by "more clever" I mean "Matt Gallagher." “更聪明”是指“马特·加拉格尔”。 Take a look at his very interesting approach in Substituting local data for remote UIWebView requests . 看看他在将本地数据替换为远程UIWebView请求时非常有趣的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在不引入View或Tab控制器的情况下将核心位置数据集成到我的空白iPhone App中? - How can I integrate core location data to my blank iPhone App without introducing View or tab controller? 如何从iPhone应用程序导入/导出数据? - How can I import/export data to/from iPhone app? 即使我的Iphone已锁定,如何运行该应用程序? - How can I run that app even when my Iphone is locked? 如何在ipad应用程序中添加iphone界面,以便在应用程序启动时选择正确的界面? - How can i add an iphone interface to a ipad app so that the proper interface is selected when the app is started? 我如何加入iPad和iPhone应用程序? - How can i join an iPad and iPhone app? 如何在越狱的iPhone上测试iPhone应用程序? - How can I test an iPhone app on my iPhone that is Jailbroken? iPhone模拟器 - 如何检测应用程序何时在模拟器上运行(这样可以设置测试数据)? - iPhone simulator - how to detect when app is running on simulator (so can setup test data)? 如何在iPhone中解析以下数据? - How can i parse following data in iPhone? 我如何通过iPhone应用程序将数据文件保存到我的网站空间 - how i can save my data file to my webspace through my iphone app 如何有选择地更新某些SQLite表以保留iphone应用更新的用户数据? - how can I selectively update some SQLite table to preserve user data for an iphone app update?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM