I have created user defaults with names below,
let prefs1 = UserDefaults.init(suiteName: "UserAccount")
let prefs2 = UserDefaults.init(suiteName: "UserInfo")
Then I have added some values to those suites. i.e.
prefs1.set(true, forKey: "Key1")
prefs1.set(true, forKey: "Key2")
prefs2.set(false, forKey: "Key1")
prefs2.set(false, forKey: "Key2")
Now, I want to remove the prefs1
(i.e. name "UserAccount"), but not prefs2
. I tried,
UserDefaults.standard.removePersistentDomain(forName: "UserAccount")
But it did not remove. I am getting confused with, forName
and suiteName
How to remove a suite from UserDefaults
keeping other suites intact in Swift?