Aggressor
Aggressor

Reputation: 13551

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!

Upvotes: 10

Views: 4526

Answers (1)

JonLord
JonLord

Reputation: 817

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

Upvotes: 2

Related Questions