---
title: NSTableViewDataSource
framework: appkit
role: symbol
role_heading: Protocol
path: appkit/nstableviewdatasource
---

# NSTableViewDataSource

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.

## Declaration

```swift
protocol NSTableViewDataSource : NSObjectProtocol
```

## Overview

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. note: View-based table views must not use the tableView(_:setObjectValue:for:row:) method for setting values. Instead the views must explicitly set the values for the fields, or use Cocoa bindings. Likewise, use target/action for editing. For more information, see NSTableView. If you’re not using Cocoa bindings to provide data to the table view, the following methods are required: numberOfRows(in:) tableView(_:objectValueFor:row:) tableView(_:setObjectValue:for:row:) (cell-based tables only) For more information, see Cocoa Bindings.

## Topics

### Getting Values

- [numberOfRows(in:)](appkit/nstableviewdatasource/numberofrows(in:).md)
- [tableView(_:objectValueFor:row:)](appkit/nstableviewdatasource/tableview(_:objectvaluefor:row:).md)

### Setting Values

- [tableView(_:setObjectValue:for:row:)](appkit/nstableviewdatasource/tableview(_:setobjectvalue:for:row:).md)

### Implementing Pasteboard Support

- [tableView(_:pasteboardWriterForRow:)](appkit/nstableviewdatasource/tableview(_:pasteboardwriterforrow:).md)

### Drag and Drop

- [Supporting Table View Drag and Drop Through File Promises](appkit/supporting-table-view-drag-and-drop-through-file-promises.md)
- [tableView(_:acceptDrop:row:dropOperation:)](appkit/nstableviewdatasource/tableview(_:acceptdrop:row:dropoperation:).md)
- [tableView(_:namesOfPromisedFilesDroppedAtDestination:forDraggedRowsWith:)](appkit/nstableviewdatasource/tableview(_:namesofpromisedfilesdroppedatdestination:fordraggedrowswith:).md)
- [tableView(_:validateDrop:proposedRow:proposedDropOperation:)](appkit/nstableviewdatasource/tableview(_:validatedrop:proposedrow:proposeddropoperation:).md)
- [tableView(_:writeRowsWith:to:)](appkit/nstableviewdatasource/tableview(_:writerowswith:to:).md)
- [tableView(_:draggingSession:willBeginAt:forRowIndexes:)](appkit/nstableviewdatasource/tableview(_:draggingsession:willbeginat:forrowindexes:).md)
- [tableView(_:updateDraggingItemsForDrag:)](appkit/nstableviewdatasource/tableview(_:updatedraggingitemsfordrag:).md)
- [tableView(_:draggingSession:endedAt:operation:)](appkit/nstableviewdatasource/tableview(_:draggingsession:endedat:operation:).md)

### Sorting

- [tableView(_:sortDescriptorsDidChange:)](appkit/nstableviewdatasource/tableview(_:sortdescriptorsdidchange:).md)

## Relationships

### Inherits From

- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

### Conforming Types

- [NSTableViewDiffableDataSource](appkit/nstableviewdiffabledatasource-c5gl.md)
- [NSTableViewDiffableDataSourceReference](appkit/nstableviewdiffabledatasourcereference.md)

## See Also

### Management

- [NSTableViewDelegate](appkit/nstableviewdelegate.md)
- [NSTableViewDiffableDataSource](appkit/nstableviewdiffabledatasource-c5gl.md)
