Apple is trying to migrate everyone from the path-as-string paradigm to a URL (i.e. file:///path/to/file.text ). The Swift API pretty much removes all path in favor of the URL .
You can still find it in Objective-C ( NSString ):
let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String let getImagePath = NSString.path(withComponents: [paths, "fileName"])
The more Swifty:
let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String let url = URL(fileURLWithPath: paths).appendingPathComponent("fileName")
source share