Rosalind Rosalind - 3 years ago 196
iOS Question

Isfirstresponder swift issue

I get a "Method does not override any method from its superclass" for a is first responder function. I looked this up online and theres no solution. could you please help me fix this. Here is the code.

public override func isFirstResponder() -> Bool {
// Return true if any of `self`'s subviews is the current first responder.
// Needs to unwrap the IBOutlets otherwise IBInspectable is crashing when using CardTextField because IBOutlets
// are not initialized yet when IBInspectable engine runs.
guard let numberInputTextField = numberInputTextField, let monthTextField = monthTextField, let yearTextField = yearTextField, let cvcTextField = cvcTextField else {
return false

return [numberInputTextField, monthTextField, yearTextField, cvcTextField]
.isEmpty == false

Here is an image of the error

Error of IsFirstResponderError

Answer Source

Try to replace this:

public override func isFirstResponder() -> Bool {

with this:

public override var isFirstResponder: Bool {

Apple doc

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download