Reputation: 7549
I want to paste HTML text(with p, br, bgcolor etc.) inside of textView. I did try the next:
var bodyText = NSAttributedString(data: body.dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: true)!, options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil, error: nil)
postBody.text = bodyText
postBody -> textView. But it prints the next error:
Cannot assign a value of type 'NSAttributedString?' to a value of type 'String!'
How can I correctly print it inside of textView?
Upvotes: 0
Views: 1421
Reputation: 57040
Instead of text
, use attributedText
.
postBody.attributedText = bodyText
Or, if you just want the text without the attributes, use NSAttributedString
's string
property.
postBody.text = bodyText?.string
Upvotes: 6