I have an app that is configured to use iCloud. I am adding a key/value to the NSUbiquitousKeyValueStore and I can retrieve it as expected across all of my devices. However, if I delete my app's iCloud data from under Settings, I would expect that all of the iCloud data I added to NSUbiquitousKeyValueStore would be deleted as well, but this is not the case. I am able to retrieve all of the data, no matter how long I want for iCloud to sync.
I have gone to developer.icloud.com and watched as my other iCloud data (I am also using Core Data over iCloud) is deleted properly, but their is no folder where NSUbiquitousKeyValueStore keeps its data from what I can tell.
Does anyone know if this is supposed to be deleted? It seems kind of like a "Cloud memory leak" if the user can't delete this.
This is how I do it:
NSUbiquitousKeyValueStore *kvStore = [NSUbiquitousKeyValueStore defaultStore];
NSDictionary *kvd = [kvStore dictionaryRepresentation];
NSArray *arr = [kvd allKeys];
for (int i=0; i < arr.count; i++){
NSString *key = [arr objectAtIndex:i];
[kvStore removeObjectForKey:key];
}
This will clear it out. #if DEBUG is to prevent you from accidentally shipping this code.
Swift 5.2
#if DEBUG
let allKeys = NSUbiquitousKeyValueStore.default.dictionaryRepresentation.keys
for key in allKeys {
NSUbiquitousKeyValueStore.default.removeObject(forKey: key)
}
#endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With