Skip to content

Instantly share code, notes, and snippets.

@Otbivnoe
Created March 16, 2018 06:32
Show Gist options
  • Save Otbivnoe/1dbbecd262af4939e748959e1efa7667 to your computer and use it in GitHub Desktop.
Save Otbivnoe/1dbbecd262af4939e748959e1efa7667 to your computer and use it in GitHub Desktop.
class SettingsService {
private enum Keys {
static let isNotificationsEnabled = "isNotificationsEnabled"
}
var isNotificationsEnabled: Bool {
get {
let isEnabled = UserDefaults.standard.value(forKey: Keys.isNotificationsEnabled) as? Bool
return isEnabled ?? true
}
set {
UserDefaults.standard.setValue(newValue, forKey: Keys.isNotificationsEnabled)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment