Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AlexanderBollbach/ed005ca18ba2f0b2f1d0cd80057e4c2d to your computer and use it in GitHub Desktop.
Save AlexanderBollbach/ed005ca18ba2f0b2f1d0cd80057e4c2d to your computer and use it in GitHub Desktop.
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