user3440639
user3440639

Reputation: 185

JSQMessages cannot override method Swift 3

For some reason I cannot override methods in Swift 3 using JSQMessages.

These methods are defined in the JSQMessagesCollectionViewDataSource

public func senderDisplayName() -> String!

public func senderId() -> String!

When I subclass JSQMessagesViewController I try to implement the methods as such:

override func senderId() -> String {
    return User.Wozniak.rawValue
}

override public func senderDisplayName() -> String! {
    return getName(.Wozniak)
}

However I get the error that it does not override any method from its super class. When I remove override it says it conflicts with an Obj-C selector.

Upvotes: 3

Views: 222

Answers (2)

Wasim Malek
Wasim Malek

Reputation: 123

I have implemented this functionality in swift 3 with following Properties

self.senderId = "my ID"
self.senderDisplayName = "Wozniac"

Upvotes: 1

Paulo Mattos
Paulo Mattos

Reputation: 19349

You might try this instead:

open override func senderId() -> String {
    ...
}

but I'm not sure if it will fix your issue completely.

According to SE-0117: Allow distinguishing between public access and public overridability, which introduces the open keyword, the rules for imported Objective-C code are (emphasis mine):

Objective-C classes and methods are always imported as open. This means that the synthesized header for an Objective-C class would pervasively replace public with open in its interface.

Of course, assuming JSQMessages is still implemented in pure Objective-C.

Upvotes: 0

Related Questions