micyukcha micyukcha - 1 year ago 132
Swift Question

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

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.

Answer Source
override func didPressSend(_ button: UIButton?, withMessageText text: String?, senderId: String?, senderDisplayName: String?, date: Date?) {
    guard let number = conversation?.smsNumber, let text = text else {
        assertionFailure("The conversation number or text is nil")

practice safe code out there.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download