Hi,
When I try to save the information provided by the user on the Settings view and come back to the settings again it does not load the previous stored information. This is how I am saving:
After entering all the fields and pressing the "submit" button, I save the information using User Defaults:
let advancedSettingArray = [self.custCodeTextField.text, self.pcsAddrTextField.text]
UserDefaults.standard.set(advancedSettingArray, forKey: "ArrayKey")
UserDefaults.standard.synchronize()
When I navigate back to the Settings page, I use the following code in ViewDidLoad() :
let defaults = UserDefaults.standard
if let myArray = defaults.object(forKey: "ArrayKey") as? [String] {
print(myArray)
}
It does not work, somehow. Can someone please tell what I am doing wrong.
Thanks,
Marc.