清空NSUserDefaults

//方法一

NSString*appDomain = [[NSBundlemainBundle]bundleIdentifier];

[[NSUserDefaults standardUserDefaults]removePersistentDomainForName:appDomain];

//方法二

- (void)resetDefaults {

NSUserDefaults* defs = [NSUserDefaults standardUserDefaults];

NSDictionary* dict = [defs dictionaryRepresentation];

for(id key in dict) {

[defs removeObjectForKey:key];

}

[defs synchronize];

}



你可能感兴趣的:(清空NSUserDefaults)