I followed the code exactly in the link: Read and write data from text file (Swift 2.2 solution) I am writing the same code in playground file I created.
let file = "file.txt"
let text = "some text"
if let dir = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.AllDomainsMask, true).first {
let path = NSURL(fileURLWithPath: dir).URLByAppendingPathComponent(file)
//writing
do {
try text.writeToURL(path, atomically: false, encoding: NSUTF8StringEncoding)
}
catch {/* error handling here */}
}
There are no error messages. The code runs fine. But I am not able to find the file - file.txt using my Mac finder.
How do I locate the file in the system?