Skip to content

Instantly share code, notes, and snippets.

@Otbivnoe
Last active August 6, 2018 13:45
Show Gist options
  • Save Otbivnoe/ac4784c2261ae95e8997da146a81feb8 to your computer and use it in GitHub Desktop.
Save Otbivnoe/ac4784c2261ae95e8997da146a81feb8 to your computer and use it in GitHub Desktop.
enum AppTheme: Int {
case light
case dark
}
class SettingsService {
var appTheme: AppTheme {
get {
if let rawValue: AppTheme.RawValue = UserDefaults.standard[#function], let theme = AppTheme(rawValue: rawValue) {
return theme
}
return .light
}
set {
UserDefaults.standard[#function] = newValue.rawValue
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment