如何创建像 iPhone 一样每周更新的新闻应用程序
我为 iPhone 创建了一些小应用程序,所以我有一些经验。我所在的一个组织问我是否可以为他们编写一个每周通讯应用程序。我认为这将是一个很好的挑战,所以我同意了。我的问题是:如何让应用程序每周更新一次,而用户无需重新下载或手动更新?我是否连接到数据库或网站?谁能给我发送一个好的教程的链接?我没能找到一个。
谢谢你!
I have created a few small apps for the iPhone so I have some experience. An organization that I'm in asked me if I could program a weekly newsletter app for them. I though it would be a good challenge so I agreed. My question is: how do I get the app to update weekly without the users having to re-download or manually update? Do I connect to a database or a website? Can anyone send me the link to a good tutorial? I wasn't able to find one.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你的问题很笼统,但我可以给你一些建议。
首先,您需要连接到为您提供新闻信息的服务。这是需要的。该服务可以向您发送一个您可以解析和显示的 xml,例如在
UITableView
中。 XML 并不是唯一的解决方案。您也可以使用 JSON。对于解析 XML,我建议您阅读 GDataXML,而对于 JSON,我建议您阅读 JSONKit 框架。但还有其他有效的框架。
然后,保存数据取决于您处理什么类型的数据。在这里您可以找到保存新闻的不同方法。保存包含新闻的 XML、序列化数据并将其保存在本地文件系统中或使用 Core-Data。
要在没有用户操作的情况下更新新闻,您必须保存应用程序上次下载新闻的时间(例如在
NSUserDefaults
中),并且每次“激活”应用程序时检查该日期并更新如果有必要的话。有很多关于如何操作的教程(在括号中我插入了您可以查看的类或框架):
NSURLConnection
类、AFNetworking)NSFileManager
类)NSUserDefaults
前三个涵盖第一步(下载)。其他三个覆盖第二个(保存)。显然您不必使用所有这些。例如,配置可以是:
用于服务的 NSURLConnection、用于解析 XML 数据的 GDataXML 以及用于保存数据的 Property-List。
希望有帮助。
Your question is very general but I could give you some suggestions.
First, you need to connect to a service that provides you news info. This is needed. The service could send you an xml that you can parse and display, for example in a
UITableView
. XML is not the only solution. You could use also JSON.For parsing XML I suggest you to read GDataXML, while for JSON JSONKit framework. But there are also other valid framework out there.
Then, to save data it depends on what kind of data you deal with. Here you could find different ways to save your news. Save an XML that contains your news, serialize data and save them in the local filesystem or use Core-Data.
To update your news without user actions, you have to save the last time when the app has downloaded news (for example in
NSUserDefaults
) and each time time the application is "activated" check for that date and update news if necessary.Out there there are plenty of tutorials on how to (in parenthesis I inserted classes or framework that you could have a look):
NSURLConnection
class, AFNetworking)NSFileManager
class)NSUserDefaults
First three cover the first step (download). Other three cover the second one (save). Obviously you have not to use all of them. For example a configuration could be:
NSURLConnection
for service, GDataXML for parsing XML data and Property-List for save data.Hope it helps.
一个更简单的方法是使其成为一个纯网络应用程序并每周更新网站。
无论如何,您的内容提供商都必须进行这些更新。
A simpler approach would be to make it a pure web app and update the website weekly.
Your content providers are going to have to do those updates anyway.
检查:向您的应用添加报亭支持< /a> 或 教程:如何让您的应用程序与报亭配合使用
Check: Adding Newsstand Support to Your App or Tutorial: How To Make Your App Work With The Newsstand