Skip to content

Instantly share code, notes, and snippets.

@nishabe
Created August 13, 2018 02:44
Show Gist options
  • Select an option

  • Save nishabe/3f6538db5396bea59b795ee55a46debf to your computer and use it in GitHub Desktop.

Select an option

Save nishabe/3f6538db5396bea59b795ee55a46debf to your computer and use it in GitHub Desktop.
SWIFT: Get Documents Directory Path
public extension FileManager {
static var documentsDirectoryURL: URL {
return FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
}
}
let docUrl = FileManager.documentsDirectoryURL
or
let docUrl = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment