store bool value in nsuserdefaults swift
struct Settings {
fileprivate struct Keys {
static let soundKey = "soundKey"
}
static var sound: Bool {
set {
UserDefaults.standard.set(newValue, forKey: Keys.soundKey)
}
get {
if UserDefaults.standard.object(forKey: Keys.soundKey) == nil {
// Value for sound not yet set ... Setting default ...
UserDefaults.standard.set(true, forKey: Keys.soundKey)
return true
}
return UserDefaults.standard.bool(forKey: Keys.soundKey)
}
}
}
Also in Swift:
- get item filter count swift
- swift corner radious of view controller
- swift how to add a completion block to a function
- parsing to double any data type in swift
- swift change enum value
- displaying button title swift stackoverflow
- Split a String into an array in Swift
- swift open url
- give background color swiftui
- swift set uicolor
- how to swift pie chart quartzcore framework
- if statement swfit
- how to set return type swift
- swift out of bound elelemnt
- swift wait 5 seconds
- enum from raw value swift
- hide bottom tab bar swift
- swift remove tableview cell
- swiftui background color
- predicate realm bool swift
- swift update uilabel text button
- store bool value in nsuserdefaults swift
- one line if statement swift
- swift thread.sleep