Clear out NSUserDefaults during backup restore.

This commit is contained in:
Matthew Chen 2018-01-12 14:09:09 -05:00
parent 67197ddf15
commit 05b034e925

View File

@ -754,6 +754,11 @@ NSString *const Keychain_ImportBackupKey = @"ImportBackupKey";
return NO;
}
// Clear out any existing keys in this instance of NSUserDefaults.
for (NSString *key in userDefaults.dictionaryRepresentation) {
[userDefaults removeObjectForKey:key];
}
// TODO: this doesn't yet remove any keys, so you end up with the "union".
for (NSString *key in dictionary) {
id value = dictionary[key];
@ -761,6 +766,8 @@ NSString *const Keychain_ImportBackupKey = @"ImportBackupKey";
[userDefaults setObject:value forKey:key];
}
[userDefaults synchronize];
return YES;
}