Reputation: 1871
I want to have a background thread that will check for updates on the server every 5 minutes and process that data. Should I use NSThread to detach a new thread and run an infinite loop and sleep that loop for every 5 minutes? and where should the thread start from, app delegate?
Is there a better option?
Upvotes: 0
Views: 798
Reputation: 19867
Create an NSThread
like you mentioned, but instead of having an infinite loop with sleeps, you'd be better off using an NSTimer
. You can initialize it with timerWithTimeInterval:invocation:repeats:
and then schedule it on the run loop your background thread.
Upvotes: 4