Argument labels do not match any available overloads

谁说胖子不能爱 提交于 2019-11-28 13:03:19

Just subclass the JSQMessage object and add your extra variable to your subclassed object. Then it will conform and have all the same methods.

Edit:

It looks like I might have miss lead you, the documentation instructs you to conform to the JSQMessageData protocol. I did it like this

class Message: NSObject, JSQMessageData {
var text_: String?
var senderId_: String?
var date_: NSDate?
var senderDisplayName_: String?
var isMediaMessage: Bool?
var score: Int?               ***** Here is your new Variable

init(text: String?, senderId: String?, senderDisplayName: String?, score: Int?, date: NSDate) {
    self.text_ = text
    self.senderId_ = senderId
    self.isOutBound_ = isOutBound
    self.date_ = date
    self.senderDisplayName_ = senderDisplayName
    self.score_ = score       *****
}

func text() -> String? {
    return text_
}
func score() -> Int? {        *****
    return score_
}

func senderId() -> String? {
    return senderId_
}

func date() -> NSDate? {
    return date_
}

func senderDisplayName() -> String? {
    return senderDisplayName_
}

func isMediaMessage() -> Bool {
    return isMediaMessage_
}

func messageHash() -> UInt {
    return UInt(self.hash)
}

}

You can still do it the other way but Protocols are the way to go.

Let me know if that helped I may have just confused you more :) But I will try and clarify. Good Luck

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!