<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 - 1.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UICollectionView/register(_:forCellWithReuseIdentifier:)-6z6t4",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UICollectionView(im)registerNib:forCellWithReuseIdentifier:"
  },
  "title" : "register(_:forCellWithReuseIdentifier:)"
}
-->

# register(_:forCellWithReuseIdentifier:)

Registers a nib file for use in creating new collection view cells.

```
func register(_ nib: UINib?, forCellWithReuseIdentifier identifier: String)
```

## Parameters

`nib`

The nib object containing the cell object. The nib file must contain only one top-level object and that object must be of the type [`UICollectionViewCell`](/documentation/UIKit/UICollectionViewCell).

`identifier`

The reuse identifier to associate with the specified nib file. This parameter must not be `nil` and must not be an empty string.

## Discussion

Prior to calling the [`dequeueReusableCell(withReuseIdentifier:for:)`](/documentation/UIKit/UICollectionView/dequeueReusableCell(withReuseIdentifier:for:)) method of the collection view, you must use this method or the [`register(_:forCellWithReuseIdentifier:)`](/documentation/UIKit/UICollectionView/register(_:forCellWithReuseIdentifier:)-3vaho) method to tell the collection view how to create a new cell of the given type. If a cell of the specified type is not currently in a reuse queue, the collection view uses the provided information to create a new cell object automatically.

If you previously registered a class or nib file with the same reuse identifier, the object you specify in the `nib` parameter replaces the old entry. You may specify `nil` for `nib` if you want to unregister the nib file from the specified reuse identifier.

---

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)