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

# init(forSupplementaryViewOfKind:with:)

Creates and returns a layout attributes object for a supplementary view based on the specified information.

```
convenience init(forSupplementaryViewOfKind elementKind: NSCollectionView.SupplementaryElementKind, with indexPath: IndexPath)
```

## Parameters

`elementKind`

A string that identifies the type of the supplementary view. Use this string to differentiate from among the supplementary views in a given section. This parameter must contain a valid value.

`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 configured with the initial attributes for the supplementary view.

## Discussion

Call this method when you need to create a layout attributes object for a supplementary view in a collection view. Supplementary views are a secondary type of content that display data related to a specific section. For example, header and footer views in a grid layout implemented using supplementary views. This method uses the parameters to set the initial values of the [`indexPath`](/documentation/AppKit/NSCollectionViewLayoutAttributes/indexPath) and [`representedElementKind`](/documentation/AppKit/NSCollectionViewLayoutAttributes/representedElementKind) properties 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)