Answer the question
In order to leave comments, you need to log in
How to fix Declaration 'pressesEnded(presses:withEvent:)' has different argument labels from any potential overrides error?
I found an application for tvOS, written in swift 2, when I tried to launch it on version 4, a bunch of errors appeared, I fixed almost everything, somewhere with the help of Fix, somewhere by googling, but there are two errors left that cannot be googled and XCode does not offer to fix them.
Declaration 'pressesEnded(presses:withEvent:)' has different argument labels from any potential
overrides
override func pressesEnded(presses: Set<UIPress>, withEvent event: UIPressesEvent?) {
if presses.first?.type == UIPressType.menu {
if let _ = (self.view as? SKView)?.scene as? MenuScene {
// default behaviour [exit to apple tv home]
super.pressesEnded(presses, with: event)
}
} else {
// default behaviour [exit to apple tv home]
super.pressesEnded(presses, with: event)
}
}
override func pressesBegan(presses: Set<UIPress>, withEvent event: UIPressesEvent?) {
if presses.first?.type == UIPressType.menu {
if let _ = (self.view as? SKView)?.scene as? MenuScene {
// default behaviour [exit to apple tv home]
super.pressesBegan(presses, with: event)
} else if let scene = (self.view as? SKView)?.scene as? GameScene {
scene.returnToMenu()
}
} else {
// default behaviour [exit to apple tv home]
super.pressesBegan(presses, with: event)
}
}
Answer the question
In order to leave comments, you need to log in
Well, after all, even Xcode itself writes to you:
For you, even Xcode has built-in documentation - ⌘ + Shift + 0
. If you enter the name of this method and look at the arguments, it becomes clear what presses
needs to be replaced _ presses
, but withEvent
you need to replace with with
Do the same with the second method.
PS If you position yourself as an iOS developer, then how will you continue if such a simple mistake causes dissonance.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question