I also had trouble using NSUserDefaults, I am no expert in Swift yet, but I can tell you what I understand of it and how it works for me:
UserDefaults works in 2 steps:
1st step: you set the data you want to save and when:
For example if you want to save something while pressing a button:
buttonPressed{
Userdefaults.standard.set(list, forKey: "anyKeyYouWantHere") --> however the "list" variable looks
like at the moment you press the button it will be saved just like that
}
2nd step
If for example I want to load the list back when the view loads, in ViewDidLoad I just give the variable "list" back the value it had just before I closed the app;
As so:
list = UserDefaults.standard.string(forKey: "theSameKeyFromStep1")
Hope this makes sense to you! Good luck!