A set of methods that a table view uses to provide data to a table view and to allow the editing of the table view's data source object.


@protocol NSTableViewDataSource


Some of the methods in this protocol, such as tableView:objectValueForTableColumn:row: and numberOfRowsInTableView: along with other methods that return data, are called frequently, so they must be efficient.

If you’re not using Cocoa bindings to provide data to the table view, the following methods are required:

To learn more about Cocoa bindings, see Cocoa Bindings Programming Topics.


Getting Values

- numberOfRowsInTableView:

Returns the number of records managed for aTableView by the data source object.

- tableView:objectValueForTableColumn:row:

Called by the table view to return the data object associated with the specified row and column.

Setting Values

- tableView:setObjectValue:forTableColumn:row:

Sets the data object for an item in the specified row and column.

Implementing Pasteboard Support

- tableView:pasteboardWriterForRow:

Called to allow the table to support multiple item dragging.

Drag and Drop

- tableView:acceptDrop:row:dropOperation:

Called by aTableView when the mouse button is released over a table view that previously decided to allow a drop.

- tableView:namesOfPromisedFilesDroppedAtDestination:forDraggedRowsWithIndexes:

Returns an array of filenames that represent the indexSet rows for a drag to dropDestination.

- tableView:validateDrop:proposedRow:proposedDropOperation:

Used by aTableView to determine a valid drop target.

- tableView:writeRowsWithIndexes:toPasteboard:

Returns a Boolean value that indicates whether a drag operation is allowed.

- tableView:draggingSession:willBeginAtPoint:forRowIndexes:

Implement this method to determine when a dragging session will begin.

- tableView:updateDraggingItemsForDrag:

Implement this method to allow the table to update dragging items as they are dragged over a view.

- tableView:draggingSession:endedAtPoint:operation:

Implement this method to determine when a dragging session has ended.


- tableView:sortDescriptorsDidChange:

Called by aTableView to indicate that sorting may need to be done.


Inherits From

See Also



A set of optional methods you implement in a table view delegate to customize the behavior of the table view.