Take the 2-minute tour ×

I'm wondering if there is a reason to use one over the other in KVO vs NSNotificationCenter observations. Performance, memory usage, speed, etc?

share|improve this question

1 Answer 1

up vote 9 down vote accepted

The two are not always interchangeable. Conceptually, KVO is only for observing a property of an object. For example, you can't use KVO to replace NSApplicationWillTerminateNotification because it notifies observers about an event happening, not a change in a property of an object.

As for performance and memory usage, they are both fast and use negligible memory. NSNotificationQueue has coalescing to stop floods of notifications. KVO doesn't have any coalescing as far as I know, which did cause performance issues for me at one point. I was observing hundreds of objects, and when a batch update happened to those objects I'd get hundreds of KVO callbacks. It wasn't a performance issue with KVO itself, but with my own code running as a result of the batch update.

Performance isn't really the issue, it's more about the best fit for the problem. If it's a property change, use KVO. If it's not a property change, use a delegate or a notification depending on whether you need a single observer or multiple observers.

share|improve this answer
Ah. Didn't know about the aggregation of notifications. That's a fairly important thing for me. –  David Sep 20 '11 at 4:39
Notifications are best used where there is no need for one object to know about some specific other object. For example, you might want to refresh a bunch of views if some setting changes in your app and with notifications those views do not have to have any knowledge of the object that manages the settings, which preserves MVC. –  Rob Keniger Sep 20 '11 at 12:25

Your Answer


