(informal protocol)
Framework | /System/Library/Frameworks/AppKit.framework |
Companion guide | |
Declared in | NSTableView.h |
The NSTableDataSource
informal protocol declares the methods that an instance of NSTableView
uses to access the contents of its data source object.
Note: Some of the methods in this protocol, such as tableView:objectValueForTableColumn:row:
and numberOfRowsInTableView:
along with other methods that return data, are called very frequently, so they must be efficient.
– tableView:acceptDrop:row:dropOperation:
– tableView:namesOfPromisedFilesDroppedAtDestination:forDraggedRowsWithIndexes:
– tableView:validateDrop:proposedRow:proposedDropOperation:
– tableView:writeRowsWithIndexes:toPasteboard:
– tableView:writeRows:toPasteboard:
Deprecated in Mac OS X v10.4 and later
Returns the number of records managed for aTableView by the data source object.
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
The table view that sent the message.
The number of rows in aTableView.
An instance of NSTableView
uses this method to determine how many rows it should create and display.
NSTableView.h
Invoked by aTableView when the mouse button is released over a table view that previously decided to allow a drop.
- (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id < NSDraggingInfo >)info row:(NSInteger)row dropOperation:(NSTableViewDropOperation)operation
The table view that sent the message.
An object that contains more information about this dragging operation.
The index of the proposed target row.
The type of dragging operation.
YES
if the drop operation was successful, otherwise NO
.
The data source should incorporate the data from the dragging pasteboard in the implementation of this method. You can get the data for the drop operation from info using the draggingPasteboard
method.
To accept a drop on the second row, row would be 2 and operation would be NSTableViewDropOn
. To accept a drop below the last row, row would be [aTableView numberOfRows]
and operation would be NSTableViewDropAbove
.
Implementation of this method is optional.
NSTableView.h
Returns an array of filenames that represent theindexSet rows for a drag to dropDestination.
- (NSArray *)tableView:(NSTableView *)aTableView namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination forDraggedRowsWithIndexes:(NSIndexSet *)indexSet
The table view that sent the message.
The drop location where the files are created.
The indexes of the items being dragged.
An array of filenames (not full paths) for the created files that the receiver promises to create.
This method is called when a destination has accepted a promise drag.
For more information on file promise dragging, see documentation on the NSDraggingSource
protocol and namesOfPromisedFilesDroppedAtDestination:
.
NSTableView.h
Invoked by the table view to return the data object associated with the specified row and column.
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
The table view that sent the message.
A column in in aTableView.
The row of the item in aTableColumn.
An item in the data source in the specified tableColumn of the view.
Note:
tableView:objectValueForTableColumn:row:
is called each time the table cell needs to be redisplayed, so it must be efficient.
NSTableView.h
Set the data object for an item in a given row in a given column.
- (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
The table view that sent the message.
The new value for the item.
A column in aTableView.
The row of the item in aTableColumn.
Implementation of this method is optional.
NSTableView.h
Invoked by aTableView to indicate that sorting may need to be done.
- (void)tableView:(NSTableView *)aTableView sortDescriptorsDidChange:(NSArray *)oldDescriptors
The table view that sent the message.
An array that contains the previous descriptors.
The data source typically sorts and reloads the data, and adjusts the selections accordingly. If you need to know the current sort descriptors and the data source does not manage them itself, you can get the current sort descriptors by sending aTableView a sortDescriptors
message.
Implementation of this method is optional.
NSTableView.h
Used by aTableView to determine a valid drop target.
- (NSDragOperation)tableView:(NSTableView *)aTableView validateDrop:(id < NSDraggingInfo >)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)operation
The table view that sent the message.
An object that contains more information about this dragging operation.
The index of the proposed target row.
The type of dragging operation proposed.
The dragging operation the data source will perform.
The data source may “retarget” a drop if desired by calling setDropRow:dropOperation:
and returning something other than NSDragOperationNone
. One may choose to retarget for various reasons (e.g. for better visual feedback when inserting into a sorted position).
To propose a drop on the second row, row would be 2 and operation would be NSTableViewDropOn
. To propose a drop below the last row, row would be [aTableView numberOfRows]
and operation would be NSTableViewDropAbove
.
Implementation of this method is optional.
NSTableView.h
Returns a Boolean value that indicates whether a drag operation is allowed.
- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard
The table view that sent the message.
An index set of row numbers that will be participating in the drag.
The pasteboard to which to write the drag data.
YES if the drag operation is allowed, NO otherwise.
Invoked by aTableView after it has been determined that a drag should begin, but before the drag has been started.
To refuse the drag, return NO
. To start a drag, return YES
and place the drag data onto pboard (data, owner, and so on). The drag image and other drag-related information will be set up and provided by the table view once this call returns with YES
.
Implementation of this method is optional.
NSTableView.h
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-04-10)