Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto clear NSUserDefault values in swift? [duplicate]

Tags:

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]]; 
like image 656
B.Saravana Kumar Avatar asked Jan 08 '15 04:01

B.Saravana Kumar


1 Answers

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) 
like image 54
RameshVel Avatar answered Nov 05 '22 01:11

RameshVel