import(_:fromDirectoryAt:completionHandler:)
Creates a new domain that takes ownership of on-disk data that your app previously managed without a file provider.
Declaration
class func `import`(_ domain: NSFileProviderDomain, fromDirectoryAt url: URL, completionHandler: @escaping @Sendable ((any Error)?) -> Void)class func `import`(_ domain: NSFileProviderDomain, fromDirectoryAt url: URL) async throwsParameters
- domain:
The domain to import.
- url:
A URL that points to the directory to import.
- completionHandler:
A block that the system calls as soon as it creates the new domain. It takes the following parameters:
errorIf an error occurs, this object contains information about the error; otherwise, it’s
nil.
Discussion
Use this method to migrate an existing file hierarchy on disk to a NSFileProviderExtension without redownloading the data. After you call the method, the provided URL is no longer valid. The system has moved and now manages all of its contents.
If a domain with the same name already exists, the method fails with an NSFileWriteFileExistsError error. The URL remains untouched. If the system doesn’t allow the extension to request a migration, the method fails with an NSFeatureUnsupportedError error.
The system starts by moving the provided directory into its local cache, and then calls the completion handler. Then, for each item in the directory, it calls your extension’s createItem(basedOn:fields:contents:options:request:completionHandler:) with the mayAlreadyExist option.
When the import finishes, the system calls your extension’s importDidFinish(completionHandler:) method. If you call reimportItems(below:completionHandler:) before the import finishes, the system makes a single call to importDidFinish(completionHandler:) for both imports.
See Also
Working with domains
init(for:)add(_:completionHandler:)getDomainsWithCompletionHandler(_:)remove(_:completionHandler:)remove(_:mode:completionHandler:)removeAllDomains(completionHandler:)NSFileProviderManager.DomainRemovalModedisconnect(reason:options:completionHandler:)NSFileProviderManager.DisconnectionOptionsreconnect(completionHandler:)waitForStabilization(completionHandler:)temporaryDirectoryURL()