<!--
{
  "availability" : [
    "macOS: 10.11.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSCollectionViewDelegate/collectionView(_:willDisplay:forRepresentedObjectAt:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSCollectionViewDelegate(im)collectionView:willDisplayItem:forRepresentedObjectAtIndexPath:"
  },
  "title" : "collectionView(_:willDisplay:forRepresentedObjectAt:)"
}
-->

# collectionView(_:willDisplay:forRepresentedObjectAt:)

Notifies the delegate that the specified item is about to be displayed by the collection view.

```
@MainActor optional func collectionView(_ collectionView: NSCollectionView, willDisplay item: NSCollectionViewItem, forRepresentedObjectAt indexPath: IndexPath)
```

## Parameters

`collectionView`

The collection view that is adding the item.

`item`

The item being added.

`indexPath`

The index path of the item.

## Discussion

The collection view calls this method before adding new items to its content. You can use this method to track the addition of items and perform related tasks.

---

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)