---
title: "willRemoveSubview(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsview/willremovesubview(_:)"
---

# willRemoveSubview(_:)

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

## Declaration

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

## Parameters

- `subview`: The subview that will be removed.

## Discussion

Discussion This method is invoked when subview receives a removeFromSuperview() message or subview is removed from the view due to it being added to another view with addSubview(_:).

## See Also

### Responding to View-Related Notifications

- [didAddSubview(_:)](appkit/nsview/didaddsubview(_:).md)
- [viewDidMoveToSuperview()](appkit/nsview/viewdidmovetosuperview().md)
- [viewDidMoveToWindow()](appkit/nsview/viewdidmovetowindow().md)
- [viewWillMove(toSuperview:)](appkit/nsview/viewwillmove(tosuperview:).md)
- [viewWillMove(toWindow:)](appkit/nsview/viewwillmove(towindow:).md)
