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

# willRemoveSubview(_:)

Overridden by subclasses to perform additional actions before subviews are removed from the view.

```
func willRemoveSubview(_ subview: NSView)
```

## Parameters

`subview`

The subview that will be removed.

## Discussion

This method is invoked when `subview` receives a [`removeFromSuperview()`](/documentation/AppKit/NSView/removeFromSuperview()) message or `subview` is removed from the view due to it being added to another view with [`addSubview(_:)`](/documentation/AppKit/NSView/addSubview(_:)).

---

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)