Post

Replies

Boosts

Views

Activity

User Defaults Not Working When Trying to Save the Settings Information
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.standardif 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.
14
1
10k
Nov ’18