<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSStackViewDelegate",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSStackViewDelegate"
  },
  "title" : "NSStackViewDelegate"
}
-->

# NSStackViewDelegate

A set of methods you use to respond to a stack view detaching and reattaching views.

```
protocol NSStackViewDelegate : NSObjectProtocol
```

## Overview

Adopt this protocol in a custom object and use it to track the addition and removal of views from the stack view’s view hierarchy. For an explanation of detachment and reattachment of a stack view’s views, see [`NSStackView`](/documentation/AppKit/NSStackView).

## Topics

### Responding to View Detachment and Reattachment

[`stackView(_:didReattach:)`](/documentation/AppKit/NSStackViewDelegate/stackView(_:didReattach:))

Called when the stack view has automatically reattached one or more previously-detached views.

[`stackView(_:willDetach:)`](/documentation/AppKit/NSStackViewDelegate/stackView(_:willDetach:))

Called when the stack view is about to automatically detach one or more of its views.



---

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)