---
title: "register(_:forItemWithIdentifier:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nscollectionview/register(_:foritemwithidentifier:)-6s4i"
---

# register(_:forItemWithIdentifier:)

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

## Declaration

```swift
func register(_ itemClass: AnyClass?, forItemWithIdentifier identifier: NSUserInterfaceItemIdentifier)
```

## Parameters

- `itemClass`: A class to use for creating items. The class must be descended from doc://com.apple.appkit/documentation/AppKit/NSCollectionViewItem. 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

Discussion Use this method to register the classes that represent items in your collection view. When you request an item using the makeItem(withIdentifier:for:) method, the collection view recycles an existing item with the same identifier or creates a new one by instantiating your class and calling the init() method of the resulting object. Because items are recycled to improve performance, it is recommended that your custom classes conform to the 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:) method until after you register the corresponding item.

## See Also

### Creating Collection View Items

- [makeItem(withIdentifier:for:)](appkit/nscollectionview/makeitem(withidentifier:for:).md)
- [register(_:forItemWithIdentifier:)](appkit/nscollectionview/register(_:foritemwithidentifier:)-90h1i.md)
- [makeSupplementaryView(ofKind:withIdentifier:for:)](appkit/nscollectionview/makesupplementaryview(ofkind:withidentifier:for:).md)
- [register(_:forSupplementaryViewOfKind:withIdentifier:)](appkit/nscollectionview/register(_:forsupplementaryviewofkind:withidentifier:)-3dqa.md)
- [register(_:forSupplementaryViewOfKind:withIdentifier:)](appkit/nscollectionview/register(_:forsupplementaryviewofkind:withidentifier:)-7gvf2.md)
- [NSCollectionView.SupplementaryElementKind](appkit/nscollectionview/supplementaryelementkind.md)
- [NSUserInterfaceItemIdentifier](appkit/nsuserinterfaceitemidentifier.md)
