本文只作自用笔记,不喜忽喷,诚谢纠错。
存字符串:
UserDefaults.standard.setValue("1", forKey: "login")
取字符串:
let login = UserDefaults.standard.object(forKey: "login") as! String
存数组:
let records:[String] = ["12","23"]
UserDefaults.standard.setValue(records, forKey: "records")
取数组:
let rs = UserDefaults.standard.object(forKey: "records") as! [String]