<!--
{
  "availability" : [
    "iOS: 11.0.0 - 12.0.0",
    "iPadOS: 11.0.0 - 12.0.0",
    "macCatalyst: 13.1.0 - 13.1.0"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIDocumentBrowserViewControllerDelegate/documentBrowser(_:didPickDocumentURLs:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UIDocumentBrowserViewControllerDelegate(im)documentBrowser:didPickDocumentURLs:"
  },
  "title" : "documentBrowser(_:didPickDocumentURLs:)"
}
-->

# documentBrowser(_:didPickDocumentURLs:)

Tells the delegate that the user has selected one or more documents.

```
optional func documentBrowser(_ controller: UIDocumentBrowserViewController, didPickDocumentURLs documentURLs: [URL])
```

## Parameters

`controller`

The current document browser.

`documentURLs`

An array of URLs for the selected documents.

    If the document browser’s [`allowsPickingMultipleItems`](/documentation/UIKit/UIDocumentBrowserViewController/allowsPickingMultipleItems)     property is     <doc://com.apple.documentation/documentation/Swift/true>    , the array contains one or more URLs. If     <doc://com.apple.documentation/documentation/Swift/false>    , it contains only a single URL.

## Discussion

Implement this method to process the documents selected by the user. Typically, you create a view controller to display the selected documents, then present that view modally, like in the following example.

```swift
// Did Select Documents
func documentBrowser(_ controller: UIDocumentBrowserViewController,
                     didPickDocumentURLs documentURLs: [URL]) {
    
    assert(controller.allowsPickingMultipleItems == false)
    
    assert(documentURLs.count > 0,
           "*** We received an empty array of documents ***")
    
    assert(documentURLs.count <= 1,
           "*** We received more than one document ***")
    
    guard let url = documentURLs.first else {
        fatalError("*** No URL Found! ***")
    }
    
    openDocument(controller, forFileURL: url)
}

private func openDocument(_ controller: UIDocumentBrowserViewController,
                          forFileURL url: URL) {
    
    let doc = // Create a UIDocument subclass for the selected URL.

    let editor = // Create a view controller to edit the document.

    // Optionally, set up a transition controller here...
        
    doc.open { (success) in
        guard success else {
            // Handle the error here...
        }
        
        // Present the document
        controller.present(editor, animated: true, completion: nil)
    }
}
```

---

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)