Skip to content

Instantly share code, notes, and snippets.

@irace
Created April 8, 2015 20:09
Show Gist options
  • Save irace/54d25f854a5a883bbc0e to your computer and use it in GitHub Desktop.
Save irace/54d25f854a5a883bbc0e to your computer and use it in GitHub Desktop.
Really wish protocols could be generic, but this seems to work?
protocol Options {
}
class ConcreteOptions: Options {
func hi() -> String {
return "Hi"
}
}
protocol ResponseParser {
typealias OptionsType: Options
func updateOptions(options: OptionsType)
}
class ConcreteParser: ResponseParser {
typealias OptionsType = ConcreteOptions
func updateOptions(options: ConcreteOptions) {
print(options.hi())
}
}
let parser = ConcreteParser()
parser.updateOptions(ConcreteOptions())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment