iPhone 应用程序获取 XML,然后定期刷新它
我有一个应用程序,它通过 XML 文档从网络获取一些数据。我的工作正常,并遵循了苹果 SeismicXML 示例(使用 NSURLRequest 等)。我对此很陌生,所以我不得不承认我并不完全理解获取 XML 的所有代码 - 但它正在工作。我的问题是我的应用程序可能会运行一段时间,因此我希望能够时不时地刷新 XML 并检查它是否有所不同。如果不同,我需要更新我的内容。基本上这意味着我的问题是......
- 有没有标准的方法来做到这一点?
- 我正在考虑创建一个计时器来调用解析 XML 的函数,但我不知道要调用哪个函数。
如果有人能给我任何指示或者更好的例子,那就太好了。谢谢
I have an app which gets some data from the web via an XML document. I have this working fine and have followed apples SeismicXML example (uses NSURLRequest etc). I am very new to this so I have to admit that I do not totally understand all the code that gets the XML - but it is working. My problem is that my app may be running for some time so I want to be able to refresh the XML every now and again and check to see if it is different. If it is different I need to update my contents. Basically this means my questions are....
- Is there a standard way of doing this?
- I was thinking of creating a timer to call the function which parses the XML but I can't figure out which function to call.
If anyone can give me any pointers or even better examples of this it would be fab. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NSTimer 是启动需要每 x 秒执行一次的进程的方法。
它设置了一个 5 秒的计时器来调用
theXMLMethod
方法。An NSTimer is the way to kick off a process that needs performing every x seconds
This sets a timer of 5 seconds that calls the
theXMLMethod
method.