NSCollection protocol defines methods for managing the behavior of a collection view. 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.
- macOS 10.6+
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 dropping of content into the collection view, implement the
View(_: validate Drop: proposed Index Path: drop Operation:)
View(_: accept Drop: index Path: drop Operation:)
For more information about handling drag and drop operations, see Drag and Drop Programming Topics.
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.