iOS Developer Library — Pre-Release

Developer

UIKit Framework Reference UIDocumentPickerViewController Class Reference

Options
Deployment Target:

On This Page
Language:

UIDocumentPickerViewController

A UIDocumentPickerViewController object lets the user select documents or destinations outside your app’s sandbox. You must enable iCloud document support before you can use the document picker. For more information, see iCloud Design Guide. More...

Inheritance


Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 8.0 and later.
  • Initializes and returns a document picker that can import or open the given file types.

    Declaration

    Swift

    init(documentTypes allowedUTIs: [AnyObject], inMode mode: UIDocumentPickerMode)

    Objective-C

    - (instancetype)initWithDocumentTypes:(NSArray *)allowedUTIs inMode:(UIDocumentPickerMode)mode

    Parameters

    allowedUTIs

    An array of uniform type identifiers. UTIs are strings that uniquely identify a file’s type. For more information, see Uniform Type Identifiers Overview.

    mode

    The type of file-transfer operation that the document picker performs. This argument accepts only the UIDocumentPickerModeImport or UIDocumentPickerModeOpen mode.

    Return Value

    Returns an initialized UIDocumentPickerViewController object, or nil if the object could not be successfully initialized.

    Discussion

    This method returns the document picker view controller from the most recently used Document Provider extension. It defaults back to iCloud Drive if no other valid Document Provider extension can be found.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • init(URL:inMode:) - initWithURL:inMode: Designated Initializer

    Initializes and returns a document picker that can export or move the given document.

    Declaration

    Swift

    init(URL url: NSURL, inMode mode: UIDocumentPickerMode)

    Objective-C

    - (instancetype)initWithURL:(NSURL *)url inMode:(UIDocumentPickerMode)mode

    Parameters

    url

    The document to be exported or moved.

    mode

    The type of file-transfer operation that the document picker performs. This argument accepts only the UIDocumentPickerModeExportToService or UIDocumentPickerModeMoveToService mode.

    Return Value

    Returns an initialized UIDocumentPickerViewController object, or nil if the object could not be successfully initialized.

    Discussion

    This method returns the document picker view controller from the most recently used Document Provider extension. It defaults back to iCloud Drive if no other valid Document Provider extension can be found.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • Modes that define the type of file-transfer operation used by the document picker.

    Declaration

    Swift

    enum UIDocumentPickerMode : UInt { case Import case Open case ExportToService case MoveToService }

    Objective-C

    typedef NS_ENUM (NSUInteger, UIDocumentPickerMode ) { UIDocumentPickerModeImport, UIDocumentPickerModeOpen, UIDocumentPickerModeExportToService, UIDocumentPickerModeMoveToService }

    Constants

    • Import

      UIDocumentPickerModeImport

      The document picker imports a file from outside the app’s sandbox.

      Available in iOS 8.0 and later.

    • Open

      UIDocumentPickerModeOpen

      The document picker opens an external file located outside the app’s sandbox.

      Available in iOS 8.0 and later.

    • ExportToService

      UIDocumentPickerModeExportToService

      The document picker exports a local file to a destination outside the app’s sandbox.

      Available in iOS 8.0 and later.

    • MoveToService

      UIDocumentPickerModeMoveToService

      The document picker moves a local file outside the app’s sandbox and provides access to it as an external file.

      Available in iOS 8.0 and later.

    Import Statement

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.