I have one struct
, and sometimes for some users it will crash when trying to access a variable of this type.
struct AppSettings {
var mute:Bool {
didSet {
if mute != oldValue {
let savedSettings = NSUserDefaults.standardUserDefaults()
savedSettings.setBool(mute, forKey: KEY_SETTING_MUTE)
}
}
}
init() {
let savedSettings = NSUserDefaults.standardUserDefaults()
if let savedMute = savedSettings.objectForKey(KEY_SETTING_MUTE) as? Bool {
mute = savedMute
} else {
mute = false
}
}
}
var appSettings = AppSettings()
And somewhere during application launch it sometimes crashes
if appSettings.mute {
}
This is for some users only and I cannot play it. Not being a reproduction is the worst, because it leaves me nothing wrong with the job.
Searching unsafe mutable addressor
as an error does not help, because there are almost no results.
source
share