A set of methods that you use to manage the behavior of a collection view.
SDK
- macOS 10.6+
Framework
- App
Kit
Declaration
@protocol NSCollectionViewDelegate
Overview
You use the methods of this protocol to facilitate the user-initiated selection and highlighting of items, to track changes to the collection view’s visual elements, and to implement drag and drop support. The methods of this protocol are optional, but for some features, you must implement specific methods to support the feature.
Implement the methods of this protocol in an object that you use to manage your collection view. Typically, you implement delegate support in the view controller or window controller that manages the collection view itself, but you can implement these methods in another object if you prefer. Assign your delegate object to the collection view either programmatically (by setting the value of the collection view’s delegate
property) or at design time in Interface Builder.
To implement drag and drop support in your collection view, implement the following methods:
To support the dragging of content from the collection view, implement either the
collection
orView: pasteboard Writer For Item At Index Path: collection
method.View: write Items At Index Paths: to Pasteboard: To support the dropping of content into the collection view, implement the
collection
andView: validate Drop: proposed Index Path: drop Operation: collection
methods.View: accept Drop: index Path: drop Operation: To support multi-image drag and drop, you must implement the
collection
andView: pasteboard Writer For Item At Index Path: collection
methods.View: update Dragging Items For Drag:
For more information about handling drag and drop operations, see Drag and Drop Programming Topics.
Legacy Support
Before OS X 10.11, collection views supported only a single section of items organized in a grid layout. The drag and drop methods of this protocol include variants that take a single index or an NSIndex
as a parameter. Although you can use those methods to implement your drag and drop support, it is recommended that you use the newer methods that take NSIndex
objects instead.