NSCollectionViewItem Class Reference

Inherits from
Conforms to
NSCopying
NSCoding (NSViewController)
NSCoding (NSResponder)
NSObject (NSObject)
NSEditor (Informal Protocol) (NSViewController)
NSEditorRegistration (Informal Protocol) (NSViewController)
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in OS X v10.5 and later.
Companion guide
Declared in
NSCollectionView.h
Related sample code

Overview

The NSCollectionViewItem class is a view controller subclass that manages the relationship between a compound view and the model object that provides its content.

New instances of NSCollectionViewItem are created using the NSCollectionView method newItemForRepresentedObject:. See NSCollectionView Class Reference for details.

Tasks

Getting and Setting Image and Text Fields

Managing the Selection

Parent Collection View

Dragging Components

Setting the Represented Object

Modifying the View

Properties

collectionView

Returns the receiver’s collection view. (read-only)

@property(readonly) NSCollectionView *collectionView
Discussion

This method return’s the receiver’s collection view.

Availability
  • Available in OS X v10.5 and later.
Declared In
NSCollectionView.h

draggingImageComponents

Dragging images for multi-image drag and drop support. (read-only)

@property(readonly) NSArray *draggingImageComponents
Discussion

The component frames are relative to a coordinate system that has its origin at the bottom left, so you need to take into account the flipped state of your view when computing the component frames.

This methods can be subclassed and overridden to provide a custom set of NSDraggingImageComponent objects to create the drag image.

The default implementation will return an array of up to two NSDraggingImageComponent instances -- one for the imageView and another for the textField (if not nil).

Availability
  • Available in OS X v10.7 and later.
Declared In
NSCollectionView.h

imageView

An image view to display an image in the collection item.

@property(assign) NSImageView *imageView
Availability
  • Available in OS X v10.7 and later.
Declared In
NSCollectionView.h

selected

Specifies if the collection item is selected.

@property(getter=isSelected) BOOL selected
Discussion

YES if the receiver is selected, otherwise NO.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSCollectionView.h

textField

A text field to display a string in the collection item.

@property(assign) NSTextField *textField
Availability
  • Available in OS X v10.7 and later.
Declared In
NSCollectionView.h