Check if file is writable

 Problem

I want to check if file, at a specific location, is writable.



 Recipe


// Create a FileManager instance

let fileManager = NSFileManager.defaultManager()

// Check if file exists, given its path

if fileManager.isWritableFileAtPath("hello.swift") {
    print("File is writable")
} else {
    print("File is read-only")
}
				


 Playground