Mostrar / Ocultar Avisos

Adding a timer to a thread in Cocoa

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

3 Responses

  1. Ari Braginsky Says:

    This is handy, thanks.

  2. springrider Says:

    helps a lot! Thanks!

  3. John63 Says:

    In this world people limit their interactions to fellow members of groups with which they identify. ,

Leave a Reply