I have used this in the past.
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?)
{
self.view.endEditing(true)
}
But now in Xcode 8 beta I get this error:
Declaration touchBegan(touches:withEvent)
has different argument names from any potential overrides.
Any thoughts?
This worked for me:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.view.endEditing(true)
}
Notice the very subtle Swift 3 updates in the function parameters. On pages 20 and 21 of The Swift Programming Language (Swift 3), they explain that:
“By default, functions use their parameter names as labels for their arguments. Write a custom argument label before the parameter name, or write _ to use no argument label.”
:)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With