Instance Method

importDocumentAtURL:nextToDocumentAtURL:mode:completionHandler:

Imports a document into the same location as an existing document.

Declaration

- (void)importDocumentAtURL:(NSURL *)documentURL nextToDocumentAtURL:(NSURL *)neighbourURL mode:(UIDocumentBrowserImportMode)importMode completionHandler:(void (^)(NSURL *, NSError *))completion;

Parameters

documentURL

The URL of the document's initial location.

neighborURL

The URL of a document that is already managed by a file provider (the local file provider, the iCloud file provider, or a third-party file provider). The system imports the document into the same file provider and directory as this URL.

importMode

The mode used when importing the document. For a list of import modes, see UIDocumentBrowserImportMode.

completionHandler
importedDocumentURL

The URL of the newly imported document, or nil if an error occurred.

error

An object that describes the error, if one occurred; otherwise, it is set to nil.

Discussion

Use this method to import a document into the same file provider and directory as an existing document.

For example, to duplicate a document that's already managed by a file provider:

  1. Create a duplicate of the original file in the user's temporary directory. Be sure to give it a unique name.

  2. Call importDocumentAtURL:nextToDocumentAtURL:mode:completionHandler:, passing in the temporary file's URL as the documentURL parameter and the original file's URL as the neighborURL parameter.

The system imports the duplicate into the same file provider (the local file provider, the iCloud file provider, or a third-party file provider) and the same directory as the original file.

See Also

Responding to Browser Events

delegate

The document browser's delegate.

UIDocumentBrowserViewControllerDelegate

The protocol you implement to respond as the user interacts with the document browser.