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

# register(_:forItemWithIdentifier:)

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

```
func register(_ nib: NSNib?, forItemWithIdentifier identifier: NSUserInterfaceItemIdentifier)
```

## Parameters

`nib`

The nib object containing the item’s definition. The nib file must contain exactly one [`NSCollectionViewItem`](/documentation/AppKit/NSCollectionViewItem) object at the top level. You may use a custom subclass when configuring the object in the nib file. Specify `nil` to unregister a previously registered class or nib file.

`identifier`

The string that identifies the type of item. You use this string later when requesting new items 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 items to use in your collection view. When you request an item using the [`makeItem(withIdentifier:for:)`](/documentation/AppKit/NSCollectionView/makeItem(withIdentifier:for:)) method, the collection view recycles an existing item with the same `identifier` or creates a new one by loading the contents of your nib file.

Because items are recycled to improve performance, it is recommended that your custom item classes conform to the [`NSCollectionViewElement`](/documentation/AppKit/NSCollectionViewElement) protocol. You can use the methods of that protocol to prepare your classes for reuse.

Typically, you register your items when initializing your collection view interface. Although you can register new items at any time, you must not call the [`makeItem(withIdentifier:for:)`](/documentation/AppKit/NSCollectionView/makeItem(withIdentifier:for:)) method until after you register the corresponding item.

---

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)