Controls, Cells, and Formatters
Controls and cells lie behind the appearance and behavior of most user interface objects in Cocoa, including buttons, text fields, sliders, and browsers. Although they are quite different types of objects, they interact closely.
Controls enable users to signal their intentions to an application and thus control what is happening. Cells are rectangular areas embedded within a control. Some controls can hold multiple cells as a way to partition their surfaces into active areas. Cells can draw their own contents either as text or image (and sometimes as both), and they can respond individually to user actions. Figure 6.18 shows the relationship between controls and cells.

Figure 6-18. Controls and cells
Controls act as managers of their cells, telling them when and where to draw and notifying them when a user event (mouse click or keystroke) occurs in their areas. This division of labor, given the relative “weight” of cells and controls, conserves memory and provides a great boost to application performance. For example, a matrix of buttons can be implemented as a single control with many cells, instead of a set of individual controls.
A control does not have to have a cell associated with it, but most user interface objects available on Interface Builder’s standard palettes are cell-control combinations. Even a simple button—from Interface Builder ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access