I would like to display the String HTML in a UITextView control using swift. I found some code and tried it:
do {
let str = try NSAttributedString(data: htmlString.data(using: String.Encoding.unicode, allowLossyConversion: true)!, options: [NSDocumentTypeDocumentAttribute : NSHTMLTextDocumentType], documentAttributes: nil)
} catch {
print(error)
}
but i gives some error i am unable to understand or found any solution, which states as,
Cannot convert value of type 'NSAttributedString.DocumentAttributeKey' to expected dictionary key type 'NSAttributedString.DocumentReadingOptionKey'
I need to figure out why i am having this error. Any solution or alternate code? The other solutions are in objective-c if they either have answers they are giving the same error i tried many just because of old versions.