Search code examples
multithreadingmacoscocoanstimer

Is there any reason to move a long-interval NSTimer to a background thread?


I have an NSTimer event that fetches currency rates every 15 minutes or so. If I have the timer running on the main thread, but the action it triggers is on a background thread, will my application suffer a loss of performance? Should I put the timer on a background thread; or is having it on the main thread absolutely fine, as it doesn't use any of the application's performance until fired, each 15 minutes?


Solution

  • For simplicity's sake, keep the timer on the main thread. Timers require a runloop, which only the main thread provides for you. Background threads that wish to use timers must run their own runloop.