我正在使用此代码进行iCloud备份和还原。但是在同步后,当我尝试从另一台设备恢复价值时。我发现数据无法恢复。
我该如何调试为何无法在iCloud中还原或备份数据。
+(void) updateToiCloud {
NSDictionary *dict = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
[dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
[[NSUbiquitousKeyValueStore defaultStore] setObject:obj forKey:key];
}];
[[NSUbiquitousKeyValueStore defaultStore] synchronize];
}
+(void) updateFromiCloud {
NSUbiquitousKeyValueStore *iCloudStore = [NSUbiquitousKeyValueStore defaultStore];
NSDictionary *dict = [iCloudStore dictionaryRepresentation];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:NSUserDefaultsDidChangeNotification
object:nil];
[dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
[[NSUserDefaults standardUserDefaults] setObject:obj forKey:key];
}];
}