CHAPTER 24

image

Delegation

Delegation Defined

Delegation is a design pattern where one object asks another object for help. Protocols are an important part of Delegation, because protocols define how an object will be helped.

Delegation works by defining a protocol that will list out all the methods and properties an object will need help with. Another object, known as the delegate, will provide the help needed by adopting and implementing the protocol methods. Objects ask for help by sending messages to their delegates.

Defining Delegate Protocols

Let’s say you want to implement Delegation for your object graph that includes the Project object and ...

Get Objective-C Quick Syntax Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.