如何在 Swift for OSX 中设置文件的文件属性(例如 NSCreationDate)?
我可以在 Objective-C 中做到这一点,但不知道如何在 Swift 中做到这一点。
最佳答案
对于 swift 3 使用:
//let path = "/path/to/file"
let attributes = [
FileAttributeKey.creationDate: NSDate(),
// FileAttributeKey.modificationDate: NSDate() for modification date...
]
do {
try FileManager.default.setAttributes(attributes, ofItemAtPath: path)
} catch {
print(error)
}
关于swift - 在 Swift 中设置文件属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33846694/