【发布时间】:2017-08-02 07:32:40
【问题描述】:
macOS、swift3
苹果有一个 API Foundation > FileManager > setAttributes(_:ofItemAtPath:)
声明是 func setAttributes(_ attributes: [FileAttributeKey : Any], ofItemAtPath path: String) throws
用于设置文件的创建日期等。 我可以处理 >ofItem path:String) throws
API 说它可以返回“true”,但 swift 返回 void。有一个名为“creationDate”的属性。下划线'_'的意义是什么。
我认为“属性”是一个可变字典
var myAttributesDictionary = [FileAttributeKey : Date]()
myAttributesDictionary[FileAttributeKey.creationDate] = myDateObject
let fm = FileManger()
let xxx = fm.setAttributes(myAttributesDictionary:[FileAttributeKey : creationDate], ofItemAtPath myPath)
我尝试了很多变化,现在我很困惑,我不知道需要什么。我无法编译 setAttributes 行
【问题讨论】:
标签: macos swift3 file-attributes