<!--
{
  "availability" : [
    "macOS: 10.11.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSCollectionView/register(_:forSupplementaryViewOfKind:withIdentifier:)-7gvf2",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSCollectionView(im)registerNib:forSupplementaryViewOfKind:withIdentifier:"
  },
  "title" : "register(_:forSupplementaryViewOfKind:withIdentifier:)"
}
-->

# register(_:forSupplementaryViewOfKind:withIdentifier:)

Registers a nib file to use when creating supplementary views in the collection view.

```
func register(_ nib: NSNib?, forSupplementaryViewOfKind kind: NSCollectionView.SupplementaryElementKind, withIdentifier identifier: NSUserInterfaceItemIdentifier)
```

## Parameters

`nib`

The nib object containing the supplementary view’s definition. The nib file must contain exactly one [`NSView`](/documentation/AppKit/NSView) object at the top level and that view must conform to the [`NSCollectionViewElement`](/documentation/AppKit/NSCollectionViewElement) protocol. Specify `nil` to unregister a previously registered class or nib file.

`kind`

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`.

`identifier`

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`.

## Discussion

Use this method to register nib files containing prototype supplementary views in your collection view. When you request a view using the [`makeSupplementaryView(ofKind:withIdentifier:for:)`](/documentation/AppKit/NSCollectionView/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 loading the contents of your nib file.

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`](/documentation/AppKit/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:)`](/documentation/AppKit/NSCollectionView/makeSupplementaryView(ofKind:withIdentifier:for:)) method until after you register the corresponding view.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)