JSQMessages cannot override Swift 3 method

For some reason, I am unable to override methods in Swift 3 with JSQMessages.

These methods are defined in 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 am getting the error that it does not override any method from its superclass. When I remove the override, it says it conflicts with the Obj-C selector.

+3


source to share


2 answers


I have implemented this feature in swift 3 with the following properties



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

      

+1


source


You can try instead:

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

      

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



According to SE-0117: Allow to distinguish between public access and public reevaluation , in which a keyword is introduced open

, rules for imported Objective-C code (emphasis mine):

Objective-C classes and methods are always imported as public . This means that the synthesized title for Objective-C class replaces the ubiquitous public open in its interface.

Assuming it JSQMessages

's still implemented in pure Objective-C , of course .

0


source







All Articles