ZhouJiatao's Blog

如何清空NSUserDefaults

remove the application’s persistent domain

Objective-C

NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier];
[[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain];

Swift

if let appDomain = NSBundle.mainBundle().bundleIdentifier {
    NSUserDefaults.standardUserDefaults().removePersistentDomainForName(appDomain)
}

参考链接:http://stackoverflow.com/questions/545091/clearing-nsuserdefaults