---
title: "outlineView(_:shouldCollapseItem:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsoutlineviewdelegate/outlineview(_:shouldcollapseitem:)"
---

# outlineView(_:shouldCollapseItem:)

Returns a Boolean value that indicates whether the outline view should collapse a given item.

## Declaration

```swift
@MainActor optional func outlineView(_ outlineView: NSOutlineView, shouldCollapseItem item: Any) -> Bool
```

## Parameters

- `outlineView`: The outline view that sent the message.
- `item`: The item that should collapse.

## Return Value

Return Value true to permit outlineView to collapse item, false to deny permission.

## Discussion

Discussion The delegate can implement this method to disallow collapsing of specific items. For example, if the first row of your outline view should not be collapsed, your delegate method could contain this line of code: return [outlineView rowForItem:item]!=0;

## See Also

### Expanding and Collapsing the Outline

- [outlineView(_:shouldExpandItem:)](appkit/nsoutlineviewdelegate/outlineview(_:shouldexpanditem:).md)
