---
title: "remove(_:mode:completionHandler:)"
framework: fileprovider
role: symbol
role_heading: Type Method
path: "fileprovider/nsfileprovidermanager/remove(_:mode:completionhandler:)"
---

# remove(_:mode:completionHandler:)

Removes a domain from the File Provider extension using the specified options.

## Declaration

```swift
class func remove(_ domain: NSFileProviderDomain, mode: NSFileProviderManager.DomainRemovalMode, completionHandler: @escaping @Sendable (URL?, (any Error)?) -> Void)
```

```swift
class func remove(_ domain: NSFileProviderDomain, mode: NSFileProviderManager.DomainRemovalMode) async throws -> URL?
```

## Parameters

- `domain`: The domain to remove.
- `mode`: An option that determines how the system handles user data. For a complete list of options, see doc://com.apple.fileprovider/documentation/FileProvider/NSFileProviderManager/DomainRemovalMode.
- `completionHandler`: A block that the system calls after removing the domain. It 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: class func remove(_ domain: NSFileProviderDomain, mode: NSFileProviderManager.DomainRemovalMode) async throws -> URL? For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously.

## 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)
- [removeAllDomains(completionHandler:)](fileprovider/nsfileprovidermanager/removealldomains(completionhandler:).md)
- [NSFileProviderManager.DomainRemovalMode](fileprovider/nsfileprovidermanager/domainremovalmode.md)
- [disconnect(reason:options:completionHandler:)](fileprovider/nsfileprovidermanager/disconnect(reason:options:completionhandler:).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)
