<!--
{
  "availability" : [
    "macOS: 10.11.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSCollectionViewLayoutAttributes/init(forItemWith:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSCollectionViewLayoutAttributes(cm)layoutAttributesForItemWithIndexPath:"
  },
  "title" : "init(forItemWith:)"
}
-->

# init(forItemWith:)

Creates and returns a layout attributes object for the item at the specified index path.

```
convenience init(forItemWith indexPath: IndexPath)
```

## Parameters

`indexPath`

The index path of the item. You can use this information to identify the item in your app’s data structures. This parameter must contain a valid value.

## Return Value

A new layout attributes object containing the initial attributes for the item.

## Discussion

Call this method when you need to create a layout attributes object for an item in a collection view. Items are the main type of content presented by a collection view. Items are grouped into sections, although a collection view may have only one section. This method assigns the provided index path to the [`indexPath`](/documentation/AppKit/NSCollectionViewLayoutAttributes/indexPath) property of the returned object.

---

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)