I cant seem to find a suitable answer on SO or google.
I am hitting a web server for new data every 15 seconds. The problem is while waiting for a response from the server (a few seconds at times) my user interface is tied up. I cant seem to figure out how to start an NSTimer on a seperate thread so I can pull new data in the background, leaving my UI buttons responsive.
Any suggestions?
Thanks!
When you request from the server, you can use an asynchronous NSURLRequest to receive the data. Then, you could keep your NSTimer in the main thread, because all it would be doing is creating an asynchronous NSURLRequest every 15 seconds.
Otherwise you can create a NSTimer in the background thread by creating the timer with
Then add the timer to whatever run loop you want by calling
(Replace currentRunLoop with the run loop that you want the NSTimer to be in.)