gpt4 book ai didi

swift - 无法将类型 'NSAttributedString.DocumentAttributeKey' 的值转换为预期的字典键类型 'NSAttributedString.DocumentReadingOptionKey'

转载 作者:搜寻专家 更新时间:2023-10-31 22:26:07 28 4
gpt4 key购买 nike

<分区>

我刚刚更新到 Xcode 9 并将我的应用程序从 swift 3 转换为 swift 4 并收到此错误。我该如何解决这个问题?

 func displayText() {
do {
if url.pathExtension.lowercased() != "rtf" {
let fileContent = try String(contentsOf: url)
text.text = fileContent
} else { // Is RTF file
let attributedString = try NSAttributedString(url: url, options: [NSDocumentTypeDocumentAttribute:NSRTFTextDocumentType], documentAttributes: nil)
text.attributedText = attributedString
text.isEditable = false
}
}

得到这个错误

Cannot convert value of type 'NSAttributedString.DocumentAttributeKey' to expected dictionary key type 'NSAttributedString.DocumentReadingOptionKey'

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com