Thanks for the great article!

I fixed some bugs, and put the new version in this Gist.

Note: this version is only for picking files, not folders.

Fixed bugs:

  • inside switch sourceType case .files, you want to use folderURL instead of pickedURL to make the document. According to the documentation, “Always use the URL passed into the block instead of the value in the url parameter.”
  • inside documentFromURL(pickedURL:), missing } underneath pickedURL.stopAccessingSecurityScopedResource().

I like reading manga and writing about Swift. Check out my app, Find — look for text in real life, with outrageous speed.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store