iPhone 应用程序获取 XML,然后定期刷新它

发布于 2024-09-02 01:09:53 字数 332 浏览 3 评论 0原文

我有一个应用程序,它通过 XML 文档从网络获取一些数据。我的工作正常,并遵循了苹果 SeismicXML 示例(使用 NSURLRequest 等)。我对此很陌生,所以我不得不承认我并不完全理解获取 XML 的所有代码 - 但它正在工作。我的问题是我的应用程序可能会运行一段时间,因此我希望能够时不时地刷新 XML 并检查它是否有所不同。如果不同,我需要更新我的内容。基本上这意味着我的问题是......

  1. 有没有标准的方法来做到这一点?
  2. 我正在考虑创建一个计时器来调用解析 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....

  1. Is there a standard way of doing this?
  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

NSTimer 是启动需要每 x 秒执行一次的进程的方法。

[NSTimer scheduledTimerWithTimeInterval:5 
                                 target:self 
                               selector:@selector(theXMLMethod)
                               userInfo:nil
                                repeats:YES];

它设置了一个 5 秒的计时器来调用 theXMLMethod 方法。

An NSTimer is the way to kick off a process that needs performing every x seconds

[NSTimer scheduledTimerWithTimeInterval:5 
                                 target:self 
                               selector:@selector(theXMLMethod)
                               userInfo:nil
                                repeats:YES];

This sets a timer of 5 seconds that calls the theXMLMethod method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文