Skip to content

Instantly share code, notes, and snippets.

@Cananito
Last active September 14, 2015 04:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cananito/13986bbb843e47f4e05a to your computer and use it in GitHub Desktop.
Save Cananito/13986bbb843e47f4e05a to your computer and use it in GitHub Desktop.
rdar://22678998 Swift 2.0 GM: Selector matching error when implementing an @objc protocol's function that throws.
@objc protocol P {
func execute() throws
// Solution: https://twitter.com/jckarter/status/643189428781846528
// @objc(executeAndReturnError:) func execute() throws
}
class A : P {
// Error: Type 'A' foes not conform to protocol 'P'
// Detail 1: Protocol requires function 'execute()' with type '() throws -> ()'
// Detail 2: Objective-C method 'executeAndReturnError:' provided by method 'execute()' does not match the requirement's selector ('execute')
@objc func execute() throws {
try x()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment