Adding a timer to a thread in Cocoa
- 23rd October , 2008 by Sam in Cocoa, Objective-C, iPhone
- 3 comments
Just storing this code away for future reference. It creates a new thread and adds a timer to it’s run loop.
This code creates a new thread and calls the secondThread method on self.
You’ll need to setup a new autorelease pool and start a run loop for your new thread. Ths code below does the following.
- creates a new pool
- creates a new timer to call the secondThreadMethod method every 5 seconds
- adds the timer to the new thread’s run loop
- starts the new thread’s run loop


March 5th, 2009 at 10:57 am
This is handy, thanks.
August 14th, 2009 at 7:48 am
helps a lot! Thanks!
October 22nd, 2009 at 7:09 pm
In this world people limit their interactions to fellow members of groups with which they identify. ,