Protocol

NSTableViewDataSource

The NSTableViewDataSource protocol declares the methods that an instance of NSTableView uses to provide the data to a table view and allow editing of the contents of its data source object.

Overview

Some of the methods in this protocol, such as tableView(_:objectValueFor:row:) and numberOfRows(in:) 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.

Symbols

Getting Values

func numberOfRows(in: NSTableView)

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

func tableView(NSTableView, objectValueFor: NSTableColumn?, row: Int)

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

Setting Values

func tableView(NSTableView, setObjectValue: Any?, for: NSTableColumn?, row: Int)

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

Implementing Pasteboard Support

func tableView(NSTableView, pasteboardWriterForRow: Int)

Called to allow the table to support multiple item dragging.

Drag and Drop

func tableView(NSTableView, acceptDrop: NSDraggingInfo, row: Int, dropOperation: NSTableViewDropOperation)

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

func tableView(NSTableView, namesOfPromisedFilesDroppedAtDestination: URL, forDraggedRowsWith: IndexSet)

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

func tableView(NSTableView, writeRowsWith: IndexSet, to: NSPasteboard)

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

func tableView(NSTableView, updateDraggingItemsForDrag: NSDraggingInfo)

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

Sorting

func tableView(NSTableView, sortDescriptorsDidChange: [NSSortDescriptor])

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

Relationships

Inherits From