A set of related records, displayed in rows that represent individual records and columns that represent the attributes of those records.
- macOS 10.0+
Table views are displayed in scroll views. Beginning with macOS v10.7, you can use
NSView objects (most commonly customized
NSTable objects) instead of cells for specifying rows and columns. You can still use
NSCell objects for each row and column item if you prefer.
A table view does not store its own data; it retrieves data values as needed from a data source to which it has a weak reference. You should not, therefore, directly set data values programmatically in the table view; instead, modify the values in the data source and allow the changes to be reflected in the table view. To learn about the methods that an
NSTable object uses to provide and access the contents of its data source object, see
To customize a table view’s behavior without subclassing
NSTable, use the methods defined by the
NSTable protocol. For example, the delegate supports table column management, type-to-select functionality, row selection and editing, custom tracking, and custom views for individual columns and rows. To learn more about the table view delegate, see
NSTable is usually not necessary. Instead, you customize the table view using a delegate object (an object conforming to the
NSTable protocol) and a data source object (conforming to the
NSTable protocol), or by subclassing one of the following subcomponents: cells (when using
NSCell-based table views), the row cell view or the row view (when using
NSView-based table views), the table column class, or table column header classes.