Ios appendAttributedString返回类型为Void的值

Ios appendAttributedString返回类型为Void的值,ios,swift,nsattributedstring,Ios,Swift,Nsattributedstring,我正在尝试附加两个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.mutableC

我正在尝试附加两个
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)
但我在第三行有个错误:

无法将类型“Void”(aka“()”的值转换为指定的类型“NSAttributedString”


我怎样才能解决这个问题?谢谢

appendAttributeString
更新呼叫方。它不会返回新字符串。请尝试以下操作:

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()

例如:

//MARK: Custom functions
func getQueueAttributedString(number N: Int) -> NSAttributedString? {

    let uploadSymbolAttributes = [NSForegroundColorAttributeName: UEColor.brown.six, NSFontAttributeName: UEFont.unearthCharacterFont(13)]

    let attributedString = NSMutableAttributedString(string: UEFontCharacter.triangle_up, attributes: uploadSymbolAttributes)

    let queueAttributes = [NSForegroundColorAttributeName: UEColor.brown.six, NSFontAttributeName: UEFont.museo300(withSize: 13)]

    let queueString = NSAttributedString(string: " \(N) items queued", attributes: queueAttributes)

    attributedString.append(queueString)

    return attributedString

}
其中,
UEFont
是自定义的
UIFont
UEColor
是自定义的
UIColor
的静态结构,
UEFontCharacter
是线性图标字体