Search code examples
swiftjsqmessagesviewcontroller

Swift override method didPressSend


I am using Swift 3.0 and Xcode 8.0 and JSQMessages 7.3.4.

I am trying to implement JSQMessagesViewController and specifically, I am trying to override the didPressSend function yet it keep complaining that the method does not override any method from its superclass.

override func didPressSend(_ button: UIButton, withMessageText text: String, senderId: String, senderDisplayName: String, date: Date) {
    print("working")
}

Any thoughts on why this might be?

It also complains method cannot be an @obj override because type of parameter 5 cannot be represented in Objective-C.


Solution

  • override func didPressSend(_ button: UIButton?, withMessageText text: String?, senderId: String?, senderDisplayName: String?, date: Date?) {
        // Check to make sure we are sending something no need for blank messages.
        guard let text = text else {
            return
        }
        print("working")
        // add logic here.
    }
    

    practice safe code out there.