Created
June 4, 2014 05:03
-
-
Save anonymous/5cc0af9ba0e94434d295 to your computer and use it in GitHub Desktop.
Possible Solution for Swift Enum conforming to a protocol
This file contains 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
enum testEnum: ExampleProtocol{ | |
case a, b, c | |
var simpleDescription: String{ | |
get{ | |
return "an example enum" | |
} | |
set { | |
simpleDescription = newValue | |
} | |
} | |
mutating func adjust() { | |
simpleDescription += " (whatever)" | |
} | |
} | |
var protoEnum = testEnum.a | |
let test = protoEnum.simpleDescription |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's how I solved it based on kasei's code: