Skip to content

Instantly share code, notes, and snippets.

@Abizern
Last active January 4, 2016 14:31
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 Abizern/634d8a34a9a48f00fa04 to your computer and use it in GitHub Desktop.
Save Abizern/634d8a34a9a48f00fa04 to your computer and use it in GitHub Desktop.
NSURL extension for common directory URLs
import Foundation
/// abstract: Convenience methods for getting standard URLs
extension NSURL {
/// The URL to the Documents directory
static var documentsURL: NSURL {
return try! NSFileManager.defaultManager().URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: true)
}
/// The URL to the caches directory
static var cachesURL: NSURL {
return try! NSFileManager.defaultManager().URLForDirectory(.CachesDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: true)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment