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

# shouldInvalidateLayout(forPreferredLayoutAttributes:withOriginalAttributes:)

Returns a Boolean indicating whether changes to a cell’s layout attributes trigger a larger layout update.

```
func shouldInvalidateLayout(forPreferredLayoutAttributes preferredAttributes: NSCollectionViewLayoutAttributes, withOriginalAttributes originalAttributes: NSCollectionViewLayoutAttributes) -> Bool
```

## Parameters

`preferredAttributes`

The preferred layout attributes of an element.

`originalAttributes`

The attributes that the layout object originally suggested for the item.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the layout should be invalidated or <doc://com.apple.documentation/documentation/Swift/false> if it should not.

## Discussion

The default implementation of this method returns NO to indicate that layout is not needed. You can override this method in your custom layout classes and return a different value as needed. Your implementation of this method should determine if the new attributes would cause changes to the layout of other portions of the collection view.

If you return <doc://com.apple.documentation/documentation/Swift/true> from this method, the collection view invalidates the layout using the [`invalidateLayout(with:)`](/documentation/AppKit/NSCollectionViewLayout/invalidateLayout(with:)) method. The invalidation context passed to that method is created using the [`invalidationContext(forPreferredLayoutAttributes:withOriginalAttributes:)`](/documentation/AppKit/NSCollectionViewLayout/invalidationContext(forPreferredLayoutAttributes:withOriginalAttributes:)) method.

---

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)