A little word of warning on timers

2009-11-24

There’s some really nice utility functions in Cocoa that can make life a lot easier. Take performSelector:withObject:afterDelay: for example. It will call a function for you after a specified delay. But beware! It is the amount of time experienced by the main thread, not real time. Say you say to cocoa to call you back in 8 hours, but you put your machine to sleep for 4 hours in that period. In this scenario your selector will be called in 8+4 hours.

The moral of this story? Only use performSelector:withObject:afterDelay: for short delays.

- Möller

Lämna en kommentar

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Logga ut / Ändra )

Twitter-bild

You are commenting using your Twitter account. Logga ut / Ändra )

Facebook-foto

You are commenting using your Facebook account. Logga ut / Ändra )

Ansluter till %s

Follow

Get every new post delivered to your Inbox.