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.
source to share
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 .
source to share