Delegate vs Notification in iOS


Both terminology provide a way by which iOS object communication to each other in iOS application

Delegate

  1. faster
  2. creates a has-a relationship between the two classes
  3. Good architecure, You gain compile time checking for required methods when you use  protocols with your delegates, so you know when you compile if you’re missing any required methods
  4. One of the other benefits of delegates is that you can return something back to the owning class.
  5. Easy to understand by other developer

Notifications

  1. slower than Delegate (for one receiver)
  2. NSNotificationCenter is kind of “hack-ish” and is frequently used novice programmers which can lead to poor architecture
  3. more geared towards point to multipoint communication
  4. NSNotifications allow you to send a message to any objects, but you won’t have a link between them to communicate back and forth
  5. difficult to understand by other developer

 

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at WordPress.com.

Up ↑

%d bloggers like this: