一次性移除掉NSUserDefaults中所有的数据
2017-01-10 本文已影响22人
Nicole__Zhang
// 先将其转化为字典,然后用forin遍历删除即可
NSUserDefaults *defatluts = [NSUserDefaults standardUserDefaults];
NSDictionary *dictionary = [defatluts dictionaryRepresentation];
for(NSString *key in [dictionary allKeys]){
[defatluts removeObjectForKey:key];
[defatluts synchronize];
}