Delegation
is a design pattern in which one object sends messages to another
object—specified as its delegate—to ask for input or to notify it that an event
is occurring. Delegation is often used as an alternative to class inheritance
to extend the functionality of reusable objects. For example, before a window
changes size, it asks its delegate whether the new size is ok. The delegate
replies to the window, telling it that the suggested size is acceptable or
suggesting a better size.
Delegate
methods are typically grouped into a protocol. A protocol is basically just a
list of methods. The delegate protocol specifies all the messages an object
might send to its delegate. If a class conforms to (or adopts) a
protocol, it guarantees that it implements the required methods of a protocol.
(Protocols may also include optional methods), the application object tells its
delegate that the main startup routines have finished by sending it theapplicationDidFinishLaunching:
message. The delegate is then able to perform additional tasks if it wants.
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Delegation is a design pattern in which one object sends messages to another object—specified as its delegate—to ask for input or to notify it that an event is occurring. Delegation is often used as an alternative to class inheritance to extend the functionality of reusable objects. For example, before a window changes size, it asks its delegate whether the new size is ok. The delegate replies to the window, telling it that the suggested size is acceptable or suggesting a better size.
Delegate methods are typically grouped into a protocol. A protocol is basically just a list of methods. The delegate protocol specifies all the messages an object might send to its delegate. If a class conforms to (or adopts) a protocol, it guarantees that it implements the required methods of a protocol. (Protocols may also include optional methods), the application object tells its delegate that the main startup routines have finished by sending it theapplicationDidFinishLaunching: message. The delegate is then able to perform additional tasks if it wants.