开发者

iPhone app getting XML then refreshing it at intervals

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 tha开发者_运维知识库t 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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜