O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

For the More Curious: Run Loop Observers

You can hook more stuff into the run loop, such as an observer. A run loop observer has its callback function invoked at a number of well defined places, shown Figure 15.6. These are the observation points:

  • When the run loop is entered

  • Before timers are fired

  • After timers are fired

  • Before sources (like the CFSocket) are checked

  • Before the run loop waits for activity (blocking until it can do something)

  • After it wakes up

  • When the run loop exits

Figure 15.6  Run loop observation points

Run loop observation points

Here is a function that will register an observer:

v​o​i​d​ ​a​d​d​R​u​n​L​o​o​p​O​b​s​e​r​v​e​r​ ​(​)​ ​{​ ​ ​ ​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required