【发布时间】:2018-03-31 19:17:31
【问题描述】:
我查了documentation,方法就在那里。
当我查看 .h 文件时,我确实看到了该函数。我已经尝试清理和重建,但在迁移到 Swift 4 后仍然出现此错误。
“NSAttributedString”类型的值没有成员“addAttributes”
关于以下内容:
var options:[NSAttributedString.DocumentReadingOptionKey : Any] = [NSAttributedString.DocumentReadingOptionKey.documentType : NSAttributedString.DocumentType.html]
var attributedString = try NSAttributedString(data: data, options: options, documentAttributes: nil)
let range = (attributedString.string as NSString).range(of: attributedString.string)
attributedString.addAttributes(baseAttributes, range: range) // ERROR!
【问题讨论】:
-
这是
NSMutableAttributedString的方法。 -
啊,好吧,这一定是在翻译中丢失了。谢谢。
-
如果您愿意,可以使用
addAttribute单身。
标签: swift nsattributedstring swift4