I am trying to append two NSAttributedString
.
let string_1 : NSAttributedString = self.answerTextView.attributedText
let string_2 : NSAttributedString = handleHtml(i) // a function that returns a NSAttributedString
let finalStr : NSAttributedString = string_1.mutableCopy().appendAttributedString(string_2)
But I got an error at the third line:
Cannot convert value of type 'Void' (aka '()') to specified type 'NSAttributedString'
How can I solve this? Thanks
appendAttributedString
updates the caller. It doesn't return a new string. Try the following:
let string_1 : NSAttributedString = self.answerTextView.attributedText
let string_2 : NSAttributedString = handleHtml(i) // a function that returns a NSAttributedString
let tmpStr : NSMutableAttributedString = string_1.mutableCopy()
tmpStr.appendAttributedString(string_2)
let finalStr : NSAttributedString = tmpStr.copy()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With