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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.