从互联网下载plist(数据库)?
我正在尝试从互联网下载数据库 plist 文件。我后来将内容加载到 UITableView 中,但这并不是真正的问题(我已经弄清楚了)。我现在拥有的是我的 plist 中的足球比赛列表,但缺少结果(因为比赛尚未进行。)我成功加载了该 plist(它位于我的项目目录中)。
我使用此路径
[[NSBundle mainBundle] pathForResource:@"data" ofType:@"plist"]
我的问题是
- 如何下载数据
- 如何在下载时显示“活动指示器”?
- 下载的数据保存在哪里? (所以我使用它作为像上面那样的路径)
- 如果无法下载新版本(由于互联网连接问题),如何使应用程序使用旧版本(由于互联网连接问题)
我的地图已经提供了一个空数据库(没有结果),因此如果第一次启动期间(下载应用程序后)没有互联网连接,则可以使用此方法。
预先非常感谢!
I'm trying to download a database plist file from the internet. I later load the contents into a UITableView, but that isn't really the question (I figured it out already). What I have now is a list of football matches in my plist, with the results missing (as the matches were not played yet.) I successfully loaded that plist (it's in my project directory).
I use this path
[[NSBundle mainBundle] pathForResource:@"data" ofType:@"plist"]
My questions are
- How can I download the data
- How can I show a "activity indicator" while downloading?
- Where is the downloaded data saved? (so I use it as a path like the one above)
- How can I make the app use the older version, if the new one can't be downloaded (due to internet connection problems)
With my map I already provide an empty database (without the result), so if there is no internet connection during the first launch (after the app is downloaded), this can be used.
Thanks a lot in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 NSURLConnection 下载数据,最好在单独的线程中。
Use NSURLConnection to download data, preferably in a separate thread.
我使用了 ASIHTTPRequest 类,它工作得很好......它下载所有文件类型,而不仅仅是 .plist ...你真的可以用它做很多事情(上传...等),最好的部分是它兼容 iPhone 和 Mac OS X...文档制作精良,整个事情都附带一个示例项目: )。所以它很容易使用。
按照网站所述安装所有内容,添加框架,在要下载文件的类中导入“ASIHTTPRequest.h”。
玩弄代码(我正在发布我的......),中提琴,工作得很好而且顺利......
每个试图提供帮助的人,非常感谢!
I used ASIHTTPRequest classes, and it works pretty well... It downloads ALL filetypes, not only .plist ... you can really do many things with it (upload... etc) and the best part that it is both iPhone and Mac OS X compatible... The documentation is well made and the whole thing comes with a sample project :). So its easy to use.
Install everything like the website says, add the frameworks, import the "ASIHTTPRequest.h" in the class you want to download the files.
Play around with the code (I'm posting mine...), and viola, works nice and smooth...
Everyone who tried to help, thank you very much!!