10

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!
Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
Aggressor
  • 13,323
  • 24
  • 103
  • 182

1 Answers1

2

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

JonLord
  • 807
  • 10
  • 24