---
title: "disconnect(reason:options:completionHandler:)"
framework: fileprovider
role: symbol
role_heading: Instance Method
path: "fileprovider/nsfileprovidermanager/disconnect(reason:options:completionhandler:)"
---

# disconnect(reason:options:completionHandler:)

Disconnects the domain from the extension.

## Declaration

```swift
func disconnect(reason localizedReason: String, options: NSFileProviderManager.DisconnectionOptions = [], completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

```swift
func disconnect(reason localizedReason: String, options: NSFileProviderManager.DisconnectionOptions = []) async throws
```

## Parameters

- `localizedReason`: A localized string that describes the reason for disconnecting the domain.
- `options`: Options for the disconnection. For a complete list of valid options, see doc://com.apple.fileprovider/documentation/FileProvider/NSFileProviderManager/DisconnectionOptions.
- `completionHandler`: A block that the system calls after disconnecting the domain. The block takes the following parameter:

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func disconnect(reason localizedReason: String, options: NSFileProviderManager.DisconnectionOptions = []) async throws For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously. Call this method to disconnect the domain from the extension. While the domain is disconnected, the user can continue to browse its content, but the extension no longer receives updates about changes. Call the reconnect(completionHandler:) method to reconnect the domain.

## See Also

### Working with domains

- [init(for:)](fileprovider/nsfileprovidermanager/init(for:).md)
- [import(_:fromDirectoryAt:completionHandler:)](fileprovider/nsfileprovidermanager/import(_:fromdirectoryat:completionhandler:).md)
- [add(_:completionHandler:)](fileprovider/nsfileprovidermanager/add(_:completionhandler:).md)
- [getDomainsWithCompletionHandler(_:)](fileprovider/nsfileprovidermanager/getdomainswithcompletionhandler(_:).md)
- [remove(_:completionHandler:)](fileprovider/nsfileprovidermanager/remove(_:completionhandler:).md)
- [remove(_:mode:completionHandler:)](fileprovider/nsfileprovidermanager/remove(_:mode:completionhandler:).md)
- [removeAllDomains(completionHandler:)](fileprovider/nsfileprovidermanager/removealldomains(completionhandler:).md)
- [NSFileProviderManager.DomainRemovalMode](fileprovider/nsfileprovidermanager/domainremovalmode.md)
- [NSFileProviderManager.DisconnectionOptions](fileprovider/nsfileprovidermanager/disconnectionoptions.md)
- [reconnect(completionHandler:)](fileprovider/nsfileprovidermanager/reconnect(completionhandler:).md)
- [waitForStabilization(completionHandler:)](fileprovider/nsfileprovidermanager/waitforstabilization(completionhandler:).md)
- [temporaryDirectoryURL()](fileprovider/nsfileprovidermanager/temporarydirectoryurl().md)
