SmoothOperator SmoothOperator - 22 days ago 6
iOS Question

Swift 3 error when using didPressRightButton() (SlackTextViewController)

I am trying to implement

using the following code and it is giving me an error since migrating to
Swift 3
Xcode 8

override func didPressRightButton(sender: AnyObject?) {

if let messageToSend = self.textInputbar.textView.text {

// Save messageToSend to db
self.textInputbar.textView.text = ""

The Error that I'm now getting is,

Method does not override any method from its superclass.

I'm not sure why this appeared since
Swift 3
, Thanks in advance.


You get this error since upgrading to Swift 3 because SlackTextViewController is written in Objective-C.

Since Swift 3, the Objective-C type id is now imported as Any not AnyObject.

So when you are calling super.didPressRightButton(sender) with a sender of type AnyObject, Swift compiler can't find the method you are referring to.

Fix: Just change AnyObject to Any in your method definition. (Not sure if optionality is needed though…)