Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 类型为'的值;NSAttribute字符串';没有成员';添加属性';_Swift_Nsattributedstring_Swift4 - Fatal编程技术网

Swift 类型为'的值;NSAttribute字符串';没有成员';添加属性';

Swift 类型为'的值;NSAttribute字符串';没有成员';添加属性';,swift,nsattributedstring,swift4,Swift,Nsattributedstring,Swift4,我检查了方法,方法就在那里 当我查看.h文件时,我确实看到了函数。我尝试过清理和重建,但在迁移到Swift 4后仍然出现此错误 “NSAttributedString”类型的值没有成员“addAttributes” 关于下列事项: var options:[NSAttributedString.DocumentReadingOptionKey : Any] = [NSAttributedString.DocumentReadingOptionKey.documentType : NSAttrib

我检查了方法,方法就在那里

当我查看.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!

对于谷歌带来的其他人来说,我缺少了
import-UIKit

,这是
nsmutableAttributeString
的一种方法。啊,好吧,这一定是在翻译过程中丢失的。谢谢。如果您愿意,您可以使用
addAttribute
进行单人游戏。