NSNotificationCenter vs delegation( using protocols )? NSNotificationCenter vs delegation( using protocols )? objective-c objective-c

NSNotificationCenter vs delegation( using protocols )?


The rule of thumb here is how many clients would like to be notified of an event. If it's mainly one object (e.g. to dismiss a view or to act upon a button clicked, or to react to a failed download) then you should use the delegate model.

If the event you emit may be of an interest to many objects at once (e.g. screen rotated, memory usage, user login/logout), then you should use the NSNotificationCenter.


Their purposes are different:

  • Notification is used to broadcast messages to possibly several recipients unknown from the sender.

  • Delegation is used to send messages to a single known recipient acting on behalf of the sender.


Notifications are generally better for notifying the UI of changes the occur on other threads as well. Apple's documentation strongly discourages the use of delegates across threads where possible, both for stability and performance reasons. On the Mac, they suggest using Bindings, but since they don't exist on the iPhone, notifications are probably your next best bet.