清除NSUserDefaults的数据

方法一:

- (void)resetDefaults {
    NSUserDefaults  * defaults = [NSUserDefaults standardUserDefaults];
    NSDictionary * dict = [defaults dictionaryRepresentation];
    for(id key in dict) {
        [defaults removeObjectForKey:key];
    }
    [defaults synchronize];
}

方法二:

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

你可能感兴趣的:(清除NSUserDefaults的数据)