(informal protocol)
Framework | /System/Library/Frameworks/AppKit.framework |
Companion guide | |
Declared in | NSOutlineView.h |
NSOutlineView objects support a data source delegate in addition to the regular delegate object. The NSOutlineViewDataSource
protocol defines methods that the outline view invokes as necessary to retrieve data and information about the data from the data source delegate, and—optionally—to update data values.
The regular delegate object handles all other delegate responsibilities for the outline view.
You must implement the basic methods that provide the outline view with data: outlineView:child:ofItem:, outlineView:isItemExpandable:, outlineView:numberOfChildrenOfItem:, and outlineView:objectValueForTableColumn:byItem:. If you want to allow the user to edit values, you must implement outlineView:setObjectValue:forTableColumn:byItem:. When these methods are invoked by the table view, nil
as the item refers to the “root” item. NSOutlineView
requires that each item in the outline view be unique. In order for the collapsed state of an outline view to remain consistent between reloads you must always return the same object for an item.
Note: Some of the methods in this protocol
, such as outlineView:child:ofItem:
and outlineView:numberOfChildrenOfItem:
along with other methods that return data, are called very frequently, so they must be efficient.
– outlineView:child:ofItem:
– outlineView:isItemExpandable:
– outlineView:numberOfChildrenOfItem:
– outlineView:objectValueForTableColumn:byItem:
– outlineView:setObjectValue:forTableColumn:byItem:
– outlineView:acceptDrop:item:childIndex:
– outlineView:validateDrop:proposedItem:proposedChildIndex:
– outlineView:namesOfPromisedFilesDroppedAtDestination:forDraggedItems:
Returns a Boolean value that indicates whether a drop operation was successful.
- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id < NSDraggingInfo >)info item:(id)item childIndex:(NSInteger)index
The outline view that sent the message. outlineView must have previously allowed a drop.
An object that contains more information about this dragging operation.
The parent of the item over which the cursor was placed when the mouse button was released.
The index of the child of item over which the cursor was placed when the mouse button was released.
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.
The return value indicates success or failure of the drag operation to the system.
Implementation of this method is optional.
NSOutlineView.h
Returns the child item at the specified index of a given item.
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
The outline view that sent the message.
The index of the child item from item to return.
An item in the data source.
The child item at index of a item. If item is nil
, returns the appropriate child item of the root object.
Children of a given parent item are accessed sequentially. In order for the collapsed state of the outline view to remain consistent when it is reloaded you must always return the same object for a specified child and item.
You must implement this method.
outlineView:child:ofItem:
is called very frequently, so it must be efficient.
NSOutlineView.h
Returns a Boolean value that indicates whether in a given item is expandable.
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
The outline view that sent the message.
An item in the data source.
YES
if item can be expanded to display its children, otherwise NO
.
You must implement this method.
NSOutlineView.h
Invoked by outlineView to return the item for the archived object.
- (id)outlineView:(NSOutlineView *)outlineView itemForPersistentObject:(id)object
The outline view that sent the message.
An archived representation of an item in outlineView's data source.
The unarchived item corresponding to object. If the item is an archived object, this method may return the object.
When the outline view is restoring the saved expanded items, this method is called for each expanded item, to translate the archived object to an outline view item.
You must implement this method if you are automatically saving expanded items (that is, if autosaveExpandedItems
returns YES
).
NSOutlineView.h
Returns an array of filenames for the created files that the receiver promises to create.
- (NSArray *)outlineView:(NSOutlineView *)outlineView namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination forDraggedItems:(NSArray *)items
The outline view that sent the message.
The drop location where the files are created.
The items being dragged.
An array of filenames (not full paths) for the created files that the receiver promises to create.
For more information on file promise dragging, see documentation on the NSDraggingSource
protocol and namesOfPromisedFilesDroppedAtDestination:
.
NSOutlineView.h
Returns the number of child items encompassed by a given item.
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
The outline view that sent the message.
An item in the data source.
The number of child items encompassed by item. If item is nil
, this method should return the number of children for the top-level item.
You must implement this method.
outlineView:numberOfChildrenOfItem:
is called very frequently, so it must be efficient.
NSOutlineView.h
Invoked by outlineView to return the data object associated with the specified item.
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
The outline view that sent the message.
A column in outlineView.
An item in the data source in the specified tableColumn of the view.
The item is located in the specified tableColumn of the view.
You must implement this method.
NSOutlineView
requires that each item in the outline view be unique. In order for the collapsed state of the outline view to remain consistent when it is reloaded you must always return the same object for the specified item.
NSOutlineView.h
Invoked by outlineView to return an archived object for item.
- (id)outlineView:(NSOutlineView *)outlineView persistentObjectForItem:(id)item
The outline view that sent the message.
The item for which to return an archived object.
An archived representation of item. If the item is an archived object, this method may return the item.
When the outline view is saving the expanded items, this method is called for each expanded item, to translate the outline view item to an archived object.
You must implement this method if you are automatically saving expanded items (that is, if autosaveExpandedItems
returns YES
).
NSOutlineView.h
Set the data object for a given item in a given column.
- (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
The outline view that sent the message.
The new value for the item.
A column in outlineView.
An item in the data source in the specified tableColumn of the view.
Implementation of this method is optional.
NSOutlineView.h
Invoked by an outline view to notify the data source that the descriptors changed and the data may need to be resorted.
- (void)outlineView:(NSOutlineView *)outlineView sortDescriptorsDidChange:(NSArray *)oldDescriptors
The outline 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 itself manage them, you can get outlineView's current sort descriptors by sending it a sortDescriptors
message.
Implementation of this method is optional.
NSOutlineView.h
Used by an outline view to determine a valid drop target.
- (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id < NSDraggingInfo >)info proposedItem:(id)item proposedChildIndex:(NSInteger)index
The outline view that sent the message.
An object that contains more information about this dragging operation.
The proposed parent.
The proposed child location.
A value that indicates which dragging operation the data source will perform.
Based on the mouse position, the outline view will suggest a proposed drop location. The data source may “retarget” a drop if desired by calling setDropItem:dropChildIndex:
and returning something other than NSDragOperationNone
. You may choose to retarget for various reasons (for example, for better visual feedback when inserting into a sorted position).
Implementation of this method is optional.
NSOutlineView.h
Returns a Boolean value that indicates whether a drag operation is allowed.
- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard
The outline view that invoked the method.
An array of the items participating in the drag.
The pasteboard to which to write the drag data.
YES
if the drag operation is allowed, otherwise NO
.
Invoked by outlineView 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 the pboard (data, owner, and so on). The drag image and other drag-related information will be set up and provided by the outline view once this call returns with YES
.
Implementation of this method is optional.
NSOutlineView.h
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-02-19)