---
title: "init(forItemWith:)"
framework: appkit
role: symbol
role_heading: Initializer
path: "appkit/nscollectionviewlayoutattributes/init(foritemwith:)"
---

# init(forItemWith:)

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

## Declaration

```swift
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

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

## Discussion

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 property of the returned object.

## See Also

### Creating Layout Attributes

- [init(forSupplementaryViewOfKind:with:)](appkit/nscollectionviewlayoutattributes/init(forsupplementaryviewofkind:with:).md)
- [init(forDecorationViewOfKind:with:)](appkit/nscollectionviewlayoutattributes/init(fordecorationviewofkind:with:).md)
- [init(forInterItemGapBefore:)](appkit/nscollectionviewlayoutattributes/init(forinteritemgapbefore:).md)
- [NSCollectionView.DecorationElementKind](appkit/nscollectionview/decorationelementkind.md)
