Skip to content

Instantly share code, notes, and snippets.

@andrewwoz
Created October 16, 2019 16:52
Show Gist options
  • Save andrewwoz/ae6aa9eba5c59e343eb95b18716926f3 to your computer and use it in GitHub Desktop.
Save andrewwoz/ae6aa9eba5c59e343eb95b18716926f3 to your computer and use it in GitHub Desktop.
[Setting and getting attributes of file in swift] #fs
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