Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Value of type 'NSAttributedString' has no member 'addAttributes'

I checked the documentation and the method is there.

And when I look in the .h file I do see the function. I've tried cleaning and rebuilding and I still get this error after migrating to Swift 4.

Value of type 'NSAttributedString' has no member 'addAttributes'

On the following:

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!
like image 756
Aggressor Avatar asked Oct 19 '17 17:10

Aggressor


1 Answers

For anyone else brought here by Google, I was missing import UIKit

like image 147
JonLord Avatar answered Oct 17 '22 15:10

JonLord