NSTableView object displays data for a set of related records, with rows representing individual records and columns representing the attributes of those records.
- macOS 10.10+
Table views are displayed in scroll views. Beginning with OS X v10.7, you can use
NSView objects (most commonly customized
NSTableCellView 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
NSTableView object uses to provide and access the contents of its data source object, see
To customize a table view’s behavior without subclassing
NSTableView, use the methods defined by the
NSTableViewDelegate 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
NSTableView is usually not necessary. Instead, you customize the table view using a delegate object (an object conforming to the
NSTableViewDelegate protocol) and a data source object (conforming to the
NSTableViewDataSource 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.