Swift 3
to add value to NSUserDefault
integer
UserDefaults.standard.integer(forKey: "key")
dictionary
UserDefaults.standard.set(Dictvariable, forKey: "key")
get value from integer
key value = UserDefaults.standard.integer(forKey: "key")
get value from dictionary
let result = UserDefaults.standard.value(forKey: "key") as? [String: String] ?? [String: String]()
to remove (I have not tried this, you can try this to take it from stackoverflow 99% of its work)
UserDefaults.standard.removeObject(forKey: "yourKey")
source
share