Created
August 29, 2018 05:26
-
-
Save AlexanderBollbach/ed005ca18ba2f0b2f1d0cd80057e4c2d to your computer and use it in GitHub Desktop.
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
| func getValue<T>(forId id: String) throws -> T { | |
| for group in groups { | |
| if let value = group.getValue(forId: id) { | |
| switch value { | |
| case .enumeration(let state): | |
| if let result = state.current as? T { | |
| return result | |
| } else { | |
| throw SettingsError.noValueForId | |
| } | |
| case .toggle(let value): | |
| if let result = value as? T { | |
| return result | |
| } else { | |
| throw SettingsError.noValueForId | |
| } | |
| } | |
| } | |
| } | |
| throw SettingsError.noValueForId | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment