<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIDocumentPickerViewController",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIDocumentPickerViewController"
  },
  "title" : "UIDocumentPickerViewController"
}
-->

# UIDocumentPickerViewController

A view controller that provides access to documents or destinations outside your app’s sandbox.

```
@MainActor class UIDocumentPickerViewController
```

## Overview

Use a document picker view controller to select a document to open or export, and optionally copy. Don’t copy the document if you can avoid it. The document picker operates in two modes:

- Open a document. The user selects a document. The document picker provides access to the document, and the user can edit the document in place. Optionally, you can specify that the document picker makes a copy of the document, leaving the original unchanged.
- Export a local document. The user selects a destination. The document picker moves the document, and the user can access it and edit it in place. Optionally, you can specify that the document picker makes a copy of the document, leaving the original unchanged.

### Work with external documents

Both the open and export operations grant access to documents outside your app’s sandbox. This access gives users an unprecedented amount of flexibility when working with their documents. However, it also adds a layer of complexity to your file handling. External documents have the following additional requirements:

- The open and move operations provide security-scoped URLs for all external documents. Call the <doc://com.apple.documentation/documentation/Foundation/NSURL/startAccessingSecurityScopedResource()> method to access or bookmark these documents, and the <doc://com.apple.documentation/documentation/Foundation/NSURL/stopAccessingSecurityScopedResource()> method to release them. If you’re using a `UIDocument` subclass to manage your document, it automatically manages the security-scoped URL for you.
- Always use file coordinators (see <doc://com.apple.documentation/documentation/Foundation/NSFileCoordinator>) to read and write to external documents.
- Always use a file presenter (see <doc://com.apple.documentation/documentation/Foundation/NSFilePresenter>) when displaying the contents of an external document.
- Don’t save URLs that the open and move operations provide. You can, however, save a bookmark to these URLs after calling <doc://com.apple.documentation/documentation/Foundation/NSURL/startAccessingSecurityScopedResource()> to ensure you have access. Call the <doc://com.apple.documentation/documentation/Foundation/NSURL/bookmarkData(options:includingResourceValuesForKeys:relativeTo:)> method and pass in the <doc://com.apple.documentation/documentation/Foundation/NSURL/BookmarkCreationOptions/withSecurityScope> option, creating a bookmark that contains a security-scoped URL.

For more information about working with external documents, see [Providing access to directories](/documentation/UIKit/providing-access-to-directories) and [Adding a document browser to your app](/documentation/UIKit/adding-a-document-browser-to-your-app).

## Topics

### Creating a document picker

[`-  initWithCoder:`](/documentation/UIKit/UIDocumentPickerViewController/init(coder:))

Returns an initialized object from data in a specified unarchiver.

[`-  initForExportingURLs:`](/documentation/UIKit/UIDocumentPickerViewController/init(forExporting:))

Creates and returns a document picker that can export the types of documents you specify.

[`-  initForExportingURLs:asCopy:`](/documentation/UIKit/UIDocumentPickerViewController/init(forExporting:asCopy:))

Creates and returns a document picker that can export or copy the types of documents you specify.

[`-  initForOpeningContentTypes:`](/documentation/UIKit/UIDocumentPickerViewController/init(forOpeningContentTypes:))

Creates and returns a document picker that can open the types of documents you specify.

[`-  initForOpeningContentTypes:asCopy:`](/documentation/UIKit/UIDocumentPickerViewController/init(forOpeningContentTypes:asCopy:))

Creates and returns a document picker that can open or copy the types of documents you specify.

### Getting the user-selected document

[`delegate`](/documentation/UIKit/UIDocumentPickerViewController/delegate)

An object that acts as the delegate of the view controller.

[`UIDocumentPickerDelegate`](/documentation/UIKit/UIDocumentPickerDelegate)

A set of methods for tracking when the user selects a document or destination, or cancels the operation.

[`allowsMultipleSelection`](/documentation/UIKit/UIDocumentPickerViewController/allowsMultipleSelection)

A Boolean value that determines whether the user can select more than one document at a time.

[`directoryURL`](/documentation/UIKit/UIDocumentPickerViewController/directoryURL)

The initial directory that the document picker displays.

### Configuring a document picker

[`shouldShowFileExtensions`](/documentation/UIKit/UIDocumentPickerViewController/shouldShowFileExtensions)

A Boolean value that determines whether the browser always shows file extensions.

[`documentPickerMode`](/documentation/UIKit/UIDocumentPickerViewController/documentPickerMode)

The type of file transfer operation that the document picker uses.

[`UIDocumentPickerMode`](/documentation/UIKit/UIDocumentPickerMode)

Modes that define the type of file transfer operation that the document picker uses.

### Deprecated

[`-  initWithDocumentTypes:inMode:`](/documentation/UIKit/UIDocumentPickerViewController/init(documentTypes:in:))

Creates and returns a document picker that can open or copy the specified file types.

[`-  initWithURL:inMode:`](/documentation/UIKit/UIDocumentPickerViewController/init(url:in:))

Initializes and returns a document picker that can export or copy the specified document.

[`-  initWithURLs:inMode:`](/documentation/UIKit/UIDocumentPickerViewController/init(urls:in:))

Creates and returns a document picker that can export or move the specified documents.

## Relationships

### Conforms To

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSTouchBarProvider`](/documentation/AppKit/NSTouchBarProvider)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`UIActivityItemsConfigurationProviding`](/documentation/UIKit/UIActivityItemsConfigurationProviding)

[`UITraitChangeObservable-67e94`](/documentation/UIKit/UITraitChangeObservable-67e94)

[`Equatable`](/documentation/Swift/Equatable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`UIAppearanceContainer`](/documentation/UIKit/UIAppearanceContainer)

[`UITraitEnvironment`](/documentation/UIKit/UITraitEnvironment)

[`Sendable`](/documentation/Swift/Sendable)

[`UIStateRestoring`](/documentation/UIKit/UIStateRestoring)

[`NSExtensionRequestHandling`](/documentation/Foundation/NSExtensionRequestHandling)

[`UIUserActivityRestoring`](/documentation/UIKit/UIUserActivityRestoring)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`UIContentContainer`](/documentation/UIKit/UIContentContainer)

[`UIResponderStandardEditActions`](/documentation/UIKit/UIResponderStandardEditActions)

[`UIFocusEnvironment`](/documentation/UIKit/UIFocusEnvironment)

[`UIPasteConfigurationSupporting`](/documentation/UIKit/UIPasteConfigurationSupporting)

[`Hashable`](/documentation/Swift/Hashable)

### Inherits From

[`UIViewController`](/documentation/UIKit/UIViewController)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)