<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSCollectionViewLayout/prepare()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSCollectionViewLayout(im)prepareLayout"
  },
  "title" : "prepare()"
}
-->

# prepare()

Prepares the layout object to begin laying out content.

```
func prepare()
```

## Discussion

The default implementation of this method does nothing. During the layout cycle, the collection view calls this method first to give you a chance to prepare any data needed during the layout operation. When defining a custom layout, you can override this method and use it to set up data structures or perform any initial computations needed to perform the layout later.

---

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)