Home

NSCollectionView

NSCollectionView is a macOS user interface component in AppKit that presents a scrollable collection of views, typically arranged in a grid or list. It is the macOS counterpart to UICollectionView and is used to display homogeneous or heterogeneous items in a flexible, reusable way.

Core concepts revolve around a layout object that defines how items are sized and positioned. The collection

Data source and delegate roles mirror other collection-based components. The NSCollectionViewDataSource protocol supplies the number of

Registration and reuse are central to performance. You register item and supplementary view classes or nibs

In practice, NSCollectionView supports selection, drag and drop, and contextual menus, and is a versatile tool

view
uses
an
NSCollectionViewLayout
to
arrange
its
content.
The
built-in
option
most
developers
start
with
is
NSCollectionViewFlowLayout,
which
supports
grid
and
list
patterns;
more
complex
or
custom
layouts
can
be
implemented
to
achieve
specific
arrangements.
Each
item
in
the
collection
is
represented
by
an
NSCollectionViewItem,
which
owns
the
view
used
to
render
content.
Supplementary
views,
such
as
headers
and
footers,
and
decoration
views
provide
additional
chrome
and
visual
structure
around
items.
sections
and
items
and
creates
the
NSCollectionViewItem
for
a
given
index
path.
The
NSCollectionViewDelegate
handles
user
interactions,
selection,
and
actions,
while
NSCollectionViewDelegateFlowLayout
can
provide
sizing
information
when
using
the
flow
layout.
with
identifiers,
then
the
collection
view
dequeues
configured
items
as
needed
via
the
data
source
method
that
creates
items
for
represented
objects
at
index
paths.
for
presenting
grids,
lists,
or
custom
content
layouts
in
AppKit-based
interfaces.