这是我的代码。这似乎是一个错误。任何人都可以帮忙。
class PopUpVC: UIViewController {
var myArray1 = ["1","2","3"]
var myArray2 = [String]()
UserDefaults.standard.set(myArray1, forKey: "array")
override func viewDidLoad() {
super.viewDidLoad()
self.myArray2 = (UserDefaults.standard.string(forKey: "array") as? [String])!
print(self.myArray)
}
答案 0 :(得分:0)
class PopUpVC: UIViewController {
var myArray1 = ["1","2","3"]
var myArray2 = [String]()
override func viewDidLoad() {
super.viewDidLoad()
UserDefaults.standard.set(myArray1, forKey: "array")
self.myArray2 = UserDefaults.standard.stringArray(forKey: "array")!
print(self.myArray2)
}