---
title: "prepare(forCollectionViewUpdates:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nscollectionviewlayout/prepare(forcollectionviewupdates:)"
---

# prepare(forCollectionViewUpdates:)

Performs needed tasks before items are inserted, deleted, or moved within the collection view.

## Declaration

```swift
func prepare(forCollectionViewUpdates updateItems: [NSCollectionViewUpdateItem])
```

## Parameters

- `updateItems`: An array of doc://com.apple.appkit/documentation/AppKit/NSCollectionViewUpdateItem objects that identify the changes being made.

## Discussion

Discussion When items are inserted, deleted, or moved, the collection view calls this method to report those changes to the layout object. The default implementation uses the provided information to plan the layout animations needed to respond to the changes. Subclasses can override this method and use it to prepare for any custom changes, but you should always call super at some point in your implementation.

## See Also

### Responding to Collection View Updates

- [finalizeCollectionViewUpdates()](appkit/nscollectionviewlayout/finalizecollectionviewupdates().md)
- [indexPathsToInsertForSupplementaryView(ofKind:)](appkit/nscollectionviewlayout/indexpathstoinsertforsupplementaryview(ofkind:).md)
- [indexPathsToInsertForDecorationView(ofKind:)](appkit/nscollectionviewlayout/indexpathstoinsertfordecorationview(ofkind:).md)
- [initialLayoutAttributesForAppearingItem(at:)](appkit/nscollectionviewlayout/initiallayoutattributesforappearingitem(at:).md)
- [initialLayoutAttributesForAppearingSupplementaryElement(ofKind:at:)](appkit/nscollectionviewlayout/initiallayoutattributesforappearingsupplementaryelement(ofkind:at:).md)
- [initialLayoutAttributesForAppearingDecorationElement(ofKind:at:)](appkit/nscollectionviewlayout/initiallayoutattributesforappearingdecorationelement(ofkind:at:).md)
- [indexPathsToDeleteForSupplementaryView(ofKind:)](appkit/nscollectionviewlayout/indexpathstodeleteforsupplementaryview(ofkind:).md)
- [indexPathsToDeleteForDecorationView(ofKind:)](appkit/nscollectionviewlayout/indexpathstodeletefordecorationview(ofkind:).md)
- [finalLayoutAttributesForDisappearingItem(at:)](appkit/nscollectionviewlayout/finallayoutattributesfordisappearingitem(at:).md)
- [finalLayoutAttributesForDisappearingSupplementaryElement(ofKind:at:)](appkit/nscollectionviewlayout/finallayoutattributesfordisappearingsupplementaryelement(ofkind:at:).md)
- [finalLayoutAttributesForDisappearingDecorationElement(ofKind:at:)](appkit/nscollectionviewlayout/finallayoutattributesfordisappearingdecorationelement(ofkind:at:).md)
