子类化JSQMessages以添加messageID属性

时间:2016-08-11 03:19:36

标签: ios swift jsqmessagesviewcontroller

你好我正在使用JSQMessagesViewcontroller来创建一个chatapp,我需要为JSQMessages添加一个额外的属性来为每条消息提供一个ID。我还需要覆盖第一个方便的init来使用这个函数:

self.JSQmessages.append(JSQCell(senderId: self.senderId,displayName: self.senderDisplayName, text: message.text))

这是他们的消息单元格的样子



public class JSQMessage : NSObject, JSQMessageData, NSCoding, NSCopying {
    public var senderId: String! { get }
    public var senderDisplayName: String! { get }
    @NSCopying public var date: NSDate! { get }
    public var isMediaMessage: Bool { get }
    public var text: String! { get }
    @NSCopying public var media: JSQMessageMediaData! { get }
    
public convenience init!(senderId: String!, displayName: String!, text: String!)
   
public init!(senderId: String!, senderDisplayName: String!, date: NSDate!, text: String!)
    
public convenience init!(senderId: String!, displayName: String!, media: JSQMessageMediaData!)
  
public init!(senderId: String!, senderDisplayName: String!, date: NSDate!, media: JSQMessageMediaData!)
}




我尝试了子类化,但我对ios开发并不陌生,并且永远无法做到正确。这是我到目前为止所做的。

class JSQCell : JSQMessage {
var MessageId: String?
 required init(senderId: String!, displayName: String!, text: String!, MessageId: String!)



required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
}

非常感谢任何帮助。

0 个答案:

没有答案