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....
- 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
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.
精彩评论