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

# viewWillDisappear()

Called when the view controller’s view is about to be removed from the view hierarchy in the window.

```
func viewWillDisappear()
```

## Discussion

You can override this method to perform tasks that are to precede the disappearance of the view controller’s view, such as stopping a continuous animation that you started in response to the [`viewDidAppear()`](/documentation/AppKit/NSViewController/viewDidAppear()) method call. This method is called when:

- The view is about to be removed from the view hierarchy of the window
- The view is about to be hidden or obscured, such as in the case of a view controller whose parent is a tab view controller and the user switched to another tab
- The window is being closed

If you override this method, call this method on `super` at some point in your implementation in case a superclass also overrides this method.

The default implementation of this method does nothing.

---

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)