Taimur Ajmal
Taimur Ajmal

Reputation: 2855

Delegate to Self Concept!

Spare me if you find this too basic and generic. But i hope answering would benefit lot of noobs out there like me.

Why we set Delegate to self?

Thanks,
Taimur

Upvotes: 1

Views: 331

Answers (2)

hotpaw2
hotpaw2

Reputation: 70693

You call a pizza parlor (object) and order a large pepperoni pizza (message).

The pizza parlor want to know who to call back (delegate) to say the pizza is on the way.

You give them your own number (self).

Upvotes: 7

Philipp Schlösser
Philipp Schlösser

Reputation: 5219

For example, a UITable has two delegates, UITableDelegate and UITableDataSource...

Let's say, you want to subclass a UITable and your newly created subclass should not only enhance the functionality of the UITable but also manage it's content. Since the contents are managed by the UITableDataSource-Delegate, your new UITable subclass would implement this protocol and you would set the delegate of the UITable to itself.

Hope, this helps!

Upvotes: 5

Related Questions