Saturday, May 23, 2015

How Not to Crash #3: NSNotification

Brent Simmons:

I have one simple, hard-and-fast rule: NSNotifications are posted on the main thread only. No exceptions. If some code is running in another thread and it needs to post a notification, it does so on the main thread.

[…]

Your notification handlers should be written so that they can deal with getting called twice. And it should be impossible for a given object to register twice for the same notification. Both.

1 Comment RSS · Twitter

[…] Previously: NSNotificationCenter With Blocks Considered Harmful, How Not to Crash #3: NSNotification. […]

Leave a Comment