iOS两种方法删除NSUserDefaults所有记录

//方法一

NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier];

[[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain];

//方法二

- (void)resetDefaults {

NSUserDefaults * defs = [NSUserDefaults standardUserDefaults];

NSDictionary * dict = [defs dictionaryRepresentation];

for(idkeyindict) {

[defs removeObjectForKey:key];

}

[defs synchronize];

}

你可能感兴趣的:(iOS两种方法删除NSUserDefaults所有记录)