Database Reference
In-Depth Information
Figure 30—Accessing an existing
NSFormatter
on an element
automatically populated. This again makes the maintenance of the code very
easy and also improves readability.
NSOutlineView
If we wanted to change the look of our application, we could display a single
NSOutlineView
instead of the two table views we are currently using. With an
NSOutlineView
, we could display a list of recipes with a hierarchy of ingredients
listed under them, as depicted in
Figure 31,
Outline view of recipes
, on page 149
.
NSOutlineView
shares a lot in common with the
NSTableView
object. In fact, it is a
subclass of
NSTableView
. The major difference is that the
NSOutlineView
displays
data in both a column format as well as a hierarchal format. This changes
how the data needs to be represented and accessed. Instead of a flat array of
objects, the
NSOutlineView
expects the data to be in a tree structure. Fortunately,
there is a controller designed just for that use:
NSTreeController
. Some care must
be taken when working with Core Data and an
NSOutlineView
. In general, the
NSOutlineView
and the
NSTreeController
expect the data to be in a fairly organized
state.
NSTreeController
expects each parent (or branch) to have children accessible
via the same methods. This is a bit counterintuitive to having descriptive