3

I'm using NSUserDefaults or Defaults with suite names.

For example: UserDefaults(suiteName: "AccountOne")?.set("Active", forKey: "AKey")

I'd like to delete all keys and values for the given suite name: AccountOne

Christopher
  • 1,327
  • 10
  • 17
  • 1
    Essentially a duplicate of https://stackoverflow.com/questions/6797096/delete-all-keys-from-a-nsuserdefaults-dictionary-ios – rmaddy Jul 13 '17 at 23:03

1 Answers1

5

UserDefaults.standard.removePersistentDomain(forName: "AccountOne")

edc1591
  • 10,146
  • 6
  • 40
  • 63
Christopher
  • 1,327
  • 10
  • 17
  • 2
    Confusingly, (since we are referencing `standard`) this is the way. – mxcl Oct 07 '17 at 23:05
  • 2
    Thanks for pointing out that the `forName:` in removePersistentDomain has to be the same as `suiteName:` when creating the UserDefaults instance. The API naming is a bit misleading :( – Hlung May 10 '18 at 14:30