How can I auto clear the nsuserdefault
values in swift? I have already tried this but it doesn't work for me...
[[NSUserDefaults standardUserDefaults] setPersistentDomain:[NSDictionary dictionary] forName:[[NSBundle mainBundle] bundleIdentifier]];
The swift counterpart for your objective-c code is this
let appDomain = NSBundle.mainBundle().bundleIdentifier! NSUserDefaults.standardUserDefaults().removePersistentDomainForName(appDomain)
Swift 3.0 and higher
let appDomain = Bundle.main.bundleIdentifier! UserDefaults.standard.removePersistentDomain(forName: appDomain)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With