Skip to content

Instantly share code, notes, and snippets.

@drosenstark
Created August 3, 2023 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drosenstark/c50932b4831bb45a7ed274744a2d28d5 to your computer and use it in GitHub Desktop.
Save drosenstark/c50932b4831bb45a7ed274744a2d28d5 to your computer and use it in GitHub Desktop.
Open the directory housing a document in the Files app
// thanks to this thing!
// https://www.macstories.net/ios/fs-bookmarks-a-shortcut-to-reopen-files-and-folders-directly-in-the-files-app/
extension URL {
func openParentDirectoryInFilesApp() {
guard var components = URLComponents(url: self.deletingLastPathComponent(), resolvingAgainstBaseURL: false) else { return }
components.scheme = "shareddocuments"
guard let newURL = components.url else { return }
if UIApplication.shared.canOpenURL(newURL) {
UIApplication.shared.open(newURL)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment