Instance Method


Registers a class to use when creating new supplementary views in the collection view.


func register(_ viewClass: AnyClass?, forSupplementaryViewOfKind kind: NSCollectionView.SupplementaryElementKind, withIdentifier identifier: NSUserInterfaceItemIdentifier)



The view class to use for the supplementary view. This class must be descended from NSView and must conform to the NSCollectionViewElement protocol. Specify nil to unregister a previously registered class or nib file.


The kind of the supplementary view. Layout objects define the kinds of supplementary views they support and are responsible for providing appropriate strings that you can pass for this parameter. This parameter must not be an empty string or nil.


The string that identifies the type of supplementary view. You use this string later when requesting new views and it must be unique among the other registered item and view classes of this collection view. This parameter must not be an empty string or nil.


Use this method to register the classes that represent the supplementary views in your collection view. When you request a view using the makeSupplementaryView(ofKind:withIdentifier:for:) method, the collection view recycles an existing view with the same identifier and kind values or creates a new one by instantiating your class and calling the init(frame:) method of the resulting object.

The layout object is responsible for defining the kind of supplementary views it supports and how those views are used. For example, the flow layout (NSCollectionViewFlowLayout class) lets you specify supplementary views to act as headers and footers for each section.

Typically, you register your supplementary views when initializing your collection view interface. Although you can register new views at any time, you must not call the makeSupplementaryView(ofKind:withIdentifier:for:) method until after you register the corresponding view.