wenn ich Code auf Swift 4 update bekomme diesen Fehler, wie kann ich das beheben? ERROR SCREEN SHOTWert des Typs '[String: Date]' kann nicht in den erwarteten Argumenttyp '[FileAttributeKey: Any]?' Konvertiert werden.
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)
}
Fehler:
Cannot convert value of type '[String : Date]' to expected argument type '[FileAttributeKey : Any]?'
andere Linie
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)
}
wieder diesen Fehler
Cannot convert value of type '[String : Any]' to expected argument type '[NSAttributedString.DocumentReadingOptionKey : Any]'
und andere Linie
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
Sie müssen Ihre Deklaration und Initialisierung Ihrer 'directoryAttributes' -Variable anzeigen. – rmaddy