---
title: "dismantleUIViewController(_:coordinator:)"
framework: swiftui
role: symbol
role_heading: Type Method
path: "swiftui/uiviewcontrollerrepresentable/dismantleuiviewcontroller(_:coordinator:)"
---

# dismantleUIViewController(_:coordinator:)

Cleans up the presented view controller (and coordinator) in anticipation of their removal.

## Declaration

```swift
@MainActor @preconcurrency static func dismantleUIViewController(_ uiViewController: Self.UIViewControllerType, coordinator: Self.Coordinator)
```

## Parameters

- `uiViewController`: Your custom view controller object.
- `coordinator`: The custom coordinator instance you use to communicate changes back to SwiftUI. If you do not use a custom coordinator, the system provides a default instance.

## Discussion

Discussion Use this method to perform additional clean-up work related to your custom view controller. For example, you might use this method to remove observers or update other parts of your SwiftUI interface.
