I am getting the error:
Cannot assign value of type 'NSMutableAttributedString' to type 'String?'
when trying to put the string into a UITextView.
I have read the following article: https://www.hackingwithswift.com/articles/113/nsattributedstring-by-example which indicates that NSAttributedString can be used with UITextView. I have also tried to convert the NSMutuableAttributedString into a String as follows:
self.text.text = String(attributedQuote)
However, this did not work.
This assigns the 'transcription' as the string to be converted to NSMutableAttributedString:
let attributedQuote = NSMutableAttributedString(string: transcription)
This adds underlining to the first word in the attributedQuote:
attributedQuote.addAttribute(.underlineStyle, value: true, range: NSRange(location: 0, length: 4))
This adds the attributedQuote to the UITextView:
self.text.text = attributedQuote
Unfortunately, I'm getting the error when I was expecting the first word to be underlined.