func init() if UserDefaults.standard.bool(forKey: "V1.0") == false { let defaults = [ "Initialized" : true, "R" : 1.0, "G" : 1.0, "B" : 1.0 ] as [String : Any] UserDefaults.standard.register(defaults: defaults) } } func loadUserDefaults() { if UserDefaults.standard.bool(forKey: "V1.0") == true { r = UserDefaults.standard.double(forKey: "R") g = UserDefaults.standard.double(forKey: "G") b = UserDefaults.standard.double(forKey: "B") } } func saveSettings() { UserDefaults.standard.set(true, forKey: "V1.0") UserDefaults.standard.set(r, forKey: "R") UserDefaults.standard.set(g, forKey: "G") UserDefaults.standard.set(b, forKey: "B") }