Created
April 8, 2015 20:09
-
-
Save irace/54d25f854a5a883bbc0e to your computer and use it in GitHub Desktop.
Really wish protocols could be generic, but this seems to work?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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