16. Hierarchies

In Cocoa, hierarchical nesting is often used to organize objects. A hierarchy of view objects is used to organize and control drawing and coordinate systems in Cocoa. The Responder Chain pattern, described in depth in Chapter 18, “Responder Chain,” leverages the view hierarchy. Hierarchies are also seen in many data models and parse trees given that most are hierarchical in nature.

Hierarchies define relationships between objects to avoid ambiguity about which objects are responsible for storage of other objects. In addition, hierarchies provide an alternative to subclassing. In Cocoa, hierarchies are used when objects have a “has-a” relationship, while subclassing is used only for a true “is-a” relationship. Hierarchies in Cocoa ...

Get Cocoa Design Patterns 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.