NSCollectionView provides a flexible
container for displaying collections of items
arranged in a customizable layout. This view manages
the display of multiple collection view items, handles
user selection and interaction, supports drag and drop
operations, and provides extensive customization
through layouts and delegate methods. It serves as
the primary interface for displaying grid-based or custom
arranged content with efficient recycling of view
components for optimal performance with large
datasets.
Returns whether the collection view allows
selection of multiple items simultaneously. When
enabled, users can select multiple collection view
items using standard multi-selection techniques such
as command-click or shift-click. When disabled,
selecting one item automatically deselects all
others, maintaining single-item selection behavior.
Returns the array of background colors used for
alternating item backgrounds in the collection
view. Background colors provide visual distinction
between items and can create striping effects or
other visual patterns to improve readability and
organization of the displayed content.
Returns the collection view layout object that
determines how items are positioned and arranged
within the collection view. The layout controls item
placement, sizing, spacing, and other visual
arrangement aspects. Different layout classes
provide various presentation styles such as grids,
flows, or custom arrangements.
Returns the array of objects that serves as the
data source for the collection view items. Each object
in the content array corresponds to one item displayed
in the collection view, with the item prototype or
registered classes determining how each object
is presented visually to the user.
Returns the object that serves as the delegate for
this collection view. The delegate handles various
aspects of user interaction, selection behavior,
drag and drop operations, and provides feedback about
item display and lifecycle events. The delegate
enables customization of the collection view's
behavior beyond its default functionality.
Returns a drag image representing the items at the
specified indexes during a drag
operation. The image provides visual feedback to
users about what content is being dragged and can be
customized to show item previews, counts, or
other relevant information. The offset parameter
specifies the image position relative to the
mouse cursor.
Returns the frame rectangle for the item at the
specified index within the collection
view's coordinate system. The frame defines the
item's position and size as determined by the
current layout, useful for hit testing, scrolling
to specific items, or custom drawing and animation
operations.
Returns the index path for the specified collection
view item object. The index path identifies
the item's position within the collection view's
section and item structure. Returns
nil if the item is not found
or is not currently associated with a valid position in
the collection view.
Returns the index path for the item located at the
specified point within the collection
view's coordinate system. This method performs hit
testing to determine which item, if any, is
positioned at the given location. Returns
nil if no item is found at the
specified point.
Returns a set of index paths identifying all
currently visible items within the collection
view's bounds. Index paths specify both section and
item positions for precise identification in
multi-section layouts. This information is
useful for optimizing updates and managing visible
content efficiently.
Returns a set of index paths for visible
supplementary elements of the specified kind.
Supplementary elements include section
headers, footers, and other layout-provided
decorative views. The index paths identify the
location of currently visible supplementary views
within the collection view's section structure.
Returns whether items in the collection view can be
selected by user interaction. When selectable,
users can click items to select them, and the
collection view manages selection state and
visual feedback. When not selectable, items are
display-only and do not respond to selection
attempts, though they may still handle other
interactions.
Returns the collection view item object currently
displayed at the specified index. This
provides access to the item's view hierarchy and
properties for direct manipulation or
inspection. Returns nil if no item
exists at the given index or if the item
is not currently visible and instantiated.
Returns the collection view item object at the
specified index path. The item may be created if
it's not currently instantiated but is within the
displayable range. Returns nil if
no item exists at the given index path or if the path is
invalid for the current content configuration.
Returns the prototype collection view item used as
a template for creating new items when content is
displayed. The prototype defines the basic
structure, appearance, and behavior that will be
copied for each item in the collection view. This
provides a convenient way to configure items
without programmatic setup.
Returns the maximum size allowed for collection
view items. Items will not be displayed larger than
this size regardless of their content or other sizing
constraints. The maximum size provides an
upper bound that prevents items from growing too
large and disrupting the overall layout and visual
balance of the collection.
Returns the maximum number of columns that the
collection view will display in its layout. This
constraint affects how items are arranged and
can force items to wrap to new rows when the column
limit is reached. The column limit provides control
over the aspect ratio and density of the collection
view's content arrangement.
Returns the maximum number of rows that the
collection view will display in its layout. This
constraint controls the vertical extent of the
collection and can force items to wrap to new
columns when the row limit is reached, depending on
the layout configuration and item arrangement strategy.
Returns the minimum size allowed for collection
view items. Items will not be displayed smaller than
this size, ensuring they remain visible and usable
even when content would naturally size smaller. The
minimum size provides a lower bound that maintains
item accessibility and visual consistency.
Creates and returns a new collection view item
configured to represent the specified
object. This method uses the item
prototype or registered classes to instantiate
and configure the item appropriately for displaying the
given represented object within the
collection view layout.
Returns the set of indexes identifying currently
selected items in the collection view. The index
set contains the positions of all items that are
currently selected, allowing access to the
selected content objects and providing information
for batch operations on the selection.
Sets whether the collection view should allow multiple
items to be selected at the same time. Multiple
selection enables users to perform batch
operations on several items and provides more
flexible interaction patterns. Single selection
mode is appropriate when only one item should be
active or highlighted at any given time.
Sets the array of background colors to be
used for item backgrounds in the collection view. The
colors cycle through the provided array to
create alternating background patterns. Pass
nil or an empty array to disable
background coloring and use the default
appearance for all items.
Sets the layout object that will control
item arrangement within the collection view. Changing
the layout can dramatically alter the visual
presentation and behavior of the collection.
The layout change may be animated depending
on the implementation and can trigger extensive
repositioning of visible items.
Sets the array of objects that will be displayed as
items in the collection view. Each object becomes the
represented object for a collection view item,
which handles the visual presentation and user
interaction. Setting new content
triggers a refresh of the displayed items to
reflect the updated data.
Sets the delegate object that will handle collection
view events and customize behavior. The delegate
receives notifications about user interactions,
selection changes, drag and drop operations, and
item lifecycle events. Pass nil to remove
the current delegate and use default behavior for all
collection view operations.
Sets the drag operations that this collection view
supports when acting as a drag source. The
operation mask determines what types of drag
operations (copy, move, link, etc.) are offered
to potential drop destinations. The local flag indicates
whether the mask applies to drops within the same
application or external destinations.
Sets the prototype collection view item
that will serve as the template for creating new
items. The prototype's configuration, including view
hierarchy, bindings, and other properties, is
copied when creating items for display. Setting a
new prototype affects subsequently created
items but does not modify existing ones.
Sets the maximum size that collection view
items are allowed to reach. Items that would
naturally size larger than this limit
are constrained to fit within the maximum bounds. This
prevents oversized items from dominating the
display and maintains consistent visual proportions
across the collection view layout.
Sets the maximum number of columns for the
collection view layout. Items will wrap to new
rows when this column limit is exceeded, creating a
constrained grid arrangement. Setting this
value affects the overall shape and organization of
the collection view's content presentation.
Sets the maximum number of rows for the
collection view layout. When this limit is
reached, the layout behavior depends on the
configuration, potentially wrapping items to
additional columns or constraining the total
number of visible items within the
specified row count.
Sets the minimum size that collection view
items must maintain. Items that would naturally
size smaller than this limit are expanded
to meet the minimum requirements. This ensures all items
remain visible and interactive while maintaining
consistent appearance standards across the
collection view.
Sets whether items in the collection view should
respond to selection attempts. Enabling selection
allows users to interact with items and receive
visual feedback about their choices. Disabling
selection creates a read-only display where items
cannot be highlighted or chosen, though other
interactions may still function.
Sets the index paths of items that should be selected
in the collection view. Index paths specify both section
and item positions, providing precise control over
selection in multi-section layouts. This
programmatically updates the selection
state and may trigger delegate notifications and
visual feedback updates.
Sets the indexes of items that should be
selected in the collection view. This
programmatically changes the selection
state, potentially triggering delegate notifications
and visual updates. The selection respects the
collection view's multiple selection settings
and other selection constraints.
Returns the supplementary view of the specified
kind at the given index path. Supplementary views
provide additional layout elements such as section
headers, footers, or decorative content that
complements the primary collection view items.
Returns nil if no supplementary view
exists at the specified location.
Recalculates and updates the layout of all
items in the collection view. This method triggers a
complete relayout operation, repositioning items
according to the current layout configuration,
content changes, and view bounds. Tiling is
typically called automatically when needed but
can be invoked manually for custom layout updates.
Returns an array of currently visible collection
view items within the collection view's bounds.
Visible items are those that are at least partially
displayed and have been instantiated for
rendering. This provides access to the actual
item objects for direct inspection or manipulation of
the currently displayed content.
Returns an array of visible supplementary views of
the specified kind. Supplementary views include
headers, footers, and other decorative or
informational views that are not primary
content items. This method provides access to
currently displayed supplementary views for
inspection or direct manipulation.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Warning the underscore at the start of the
name of this instance variable indicates that, even
though it is not technically private, it is
intended for internal use within the package, and
you should not use the variable in other code.
Returns the set of indexPaths that
should change their selection. This is sent to
inform the delegate of those items that the
collectionView would like to change to
highlightState.