Swift 类型为'的值;NSAttribute字符串';没有成员';添加属性';
我检查了方法,方法就在那里 当我查看.h文件时,我确实看到了函数。我尝试过清理和重建,但在迁移到Swift 4后仍然出现此错误 “NSAttributedString”类型的值没有成员“addAttributes” 关于下列事项:Swift 类型为'的值;NSAttribute字符串';没有成员';添加属性';,swift,nsattributedstring,swift4,Swift,Nsattributedstring,Swift4,我检查了方法,方法就在那里 当我查看.h文件时,我确实看到了函数。我尝试过清理和重建,但在迁移到Swift 4后仍然出现此错误 “NSAttributedString”类型的值没有成员“addAttributes” 关于下列事项: var options:[NSAttributedString.DocumentReadingOptionKey : Any] = [NSAttributedString.DocumentReadingOptionKey.documentType : NSAttrib
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!
对于谷歌带来的其他人来说,我缺少了
import-UIKit
,这是nsmutableAttributeString
的一种方法。啊,好吧,这一定是在翻译过程中丢失的。谢谢。如果您愿意,您可以使用addAttribute
进行单人游戏。