私は4を迅速に更新するコードをこのエラーが発生すると、これをどのように修正できますか? ERROR SCREEN SHOT'[String:Date]'型の値を期待される引数型 '[FileAttributeKey:Any]に変換できません?'
let fullPath = destination.appendingPathComponent(pathString).path
let creationDate = Date()
let directoryAttributes = [FileAttributeKey.creationDate.rawValue : creationDate,
FileAttributeKey.modificationDate.rawValue : creationDate]
do {
if isDirectory {
try fileManager.createDirectory(atPath: fullPath, withIntermediateDirectories: true, attributes: directoryAttributes)
}
else {
let parentDirectory = (fullPath as NSString).deletingLastPathComponent
try fileManager.createDirectory(atPath: parentDirectory, withIntermediateDirectories: true, attributes: directoryAttributes)
}
エラー:
Cannot convert value of type '[String : Date]' to expected argument type '[FileAttributeKey : Any]?'
他のライン
let options: [String: Any] = [
NSAttributedString.DocumentAttributeKey.documentType.rawValue: NSAttributedString.DocumentType.html,
NSAttributedString.DocumentAttributeKey.characterEncoding.rawValue: NSNumber(value: String.Encoding.utf8.rawValue)
]
try self.init(data: data, options: options, documentAttributes: nil)
}
再びこのエラー
Cannot convert value of type '[String : Any]' to expected argument type '[NSAttributedString.DocumentReadingOptionKey : Any]'
や他のライン
let opt = [
NSAttributedString.DocumentAttributeKey.documentType.rawValue: NSAttributedString.DocumentType.html,
NSAttributedString.DocumentAttributeKey.characterEncoding: String.Encoding.utf8
] as! [String : Any]
let data = string.data(using: String.Encoding.utf8)!
returnString = try! NSMutableAttributedString(data:data,options:opt as [String:AnyObject],documentAttributes:nil)
}
ERROR
Cannot convert value of type '[String : Any]' to type '[String : AnyObject]' in coercion
'directoryAttributes'変数の宣言と初期化を示す必要があります。 – rmaddy