(The code in this answer has been updated for Swift 3 and later.)
Obviously your path variable is NSURL (describing the file path). To get the path as a string, use the path property, not absoluteString :
let exists = FileManager.default.fileExists(atPath: path.path)
absoluteString returns the URL in string format, including the file: scheme file:
Example:
let url = URL(fileURLWithPath: "/path/to/foo.txt") // This is what you did: print(url.absoluteString) // Output: file:///path/to/foo.txt // This is what you want: print(url.path) // Output: /path/to/foo.txt
Martin R 07 Dec '15 at 2:02 2015-12-07 14:02
source share