Created
October 16, 2019 16:52
-
-
Save andrewwoz/ae6aa9eba5c59e343eb95b18716926f3 to your computer and use it in GitHub Desktop.
[Setting and getting attributes of file in swift] #fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let fs = FileManager.default | |
let docsURL = ... | |
let filePath = docsURL.appendingPathComponent("article.txt").path | |
// get attributes of file | |
guard let attributes = try? fs.attributesOfItem(atPath: filePath) else { | |
return | |
} | |
print(attributes) | |
// set attributes of file | |
try? fs.setAttributes([FileAttributeKey.extensionHidden: true], ofItemAtPath: filePath) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment