Nsuserdefaults removes value and key

I want to know how to remove the key and value in NSUserDefaults. removeobjectforkey removes only the value?

removeObjectForKey(string)
+4
source share
1 answer

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")
0
source

Source: https://habr.com/ru/post/1654072/


All Articles