I have a switch called soundSwitch
, I'm saving the state of the button using an userDefault
as such:
@IBAction func soundsChanged(sender: AnyObject) {
if soundSwitch.on{
defaults.setBool(true, forKey: "SoundActive")
print("Sound ON")
}else{
defaults.setBool(false, forKey: "SoundActive")
print("Sound OFF")
}
}
Currently, the actual default value is initially false when the user first launches the application.
How can I implement the defaults to be true if the user launches the app and they haven't been configured yet.
I've seen methods in Objective-C
, but nothing in Swift. From what I've seen you can do it in the app delegate somehow, or in a PList
file. How do I do either of those ones?