Vemonus Vemonus - 3 months ago 54
iOS Question

Is this overriding the method or not?

I recently was forced to update to Swift 3.0 and it seems like Xcode's conversion did not do a great job. Luckily, I am able to solve the majority of the issues manually, however, one has me a bit confused.

This line that overrode the

method in uiController worked prior to upgrading to Swift 3.0:

override func canBecomeFirstResponder() -> Bool {
return true

However, it now returns the error:

Method does not override any method from its superclass.

However, removing the
bit doesn't seem to fix it, as it raises a different error that seems to contradict the previous one:

Method 'canBecomeFirstResponder()' with Objective-C selector 'canBecomeFirstResponder' conflicts with getter for 'canBecomeFirstResponder' from superclass 'UIResponder' with the same Objective-C selector

Is there actually an override occurring? Why is Xcode giving me mixed messages here?

For reference, I have looked at this question and although it is very similar, it is about a class, and this is about a method. To be safe, I did try using the solution to that question and it further broke things and raised the same errors.


canBecomeFirstResponder was changed from a method in Swift 2.2 to a property in Swift 3.0. This means that you must change your code to override it as a property instead of a method.

 override var canBecomeFirstResponder: Bool { return true }