1.清除每个Key
/*清除所有的存储本地的数据*/
- (void)clearAllUserDefaultsData{
NSUserDefaults*userDefaults = [NSUserDefaults standardUserDefaults];
NSDictionary*dic = [userDefaults dictionaryRepresentation];
for(idkey in dic) {
[userDefaults removeObjectForKey:key];
}
[userDefaults synchronize];
}
2.清除某个Key
[userDefaults removeObjectForKey:@""];
[userDefaults synchronize];
3.清除持久域
/* 清除所有的存储本地的数据*/
- (void)clearAllUserDefaultsData{
NSString*appDomain = [[NSBundlemainBundle]bundleIdentifier];
[[NSUserDefaultsstandardUserDefaults]removePersistentDomainForName:appDomain];
}