iCloud云存储开发实例(亲测可用)
2022-05-08 本文已影响0人
不要虚度美好的时光
1. iCould Key-Value storage
#pragma mark - key-value storage
+ (void)setUpKeyValueICloudStoreWithKey:(NSString *)key value:(NSString *)value;
{
NSUbiquitousKeyValueStore *keyValueStore = [NSUbiquitousKeyValueStore defaultStore];
[keyValueStore setObject:value forKey:key];
[keyValueStore synchronize];
NSLog(@"向iCloud保存是否已经购买值:key:%@, Value: %@", key, value);
}
+ (NSString *)getKeyValueICloudStoreWithKey:(NSString *)key
{
NSUbiquitousKeyValueStore *keyValueStore = [NSUbiquitousKeyValueStore defaultStore];
NSString *testString = [keyValueStore objectForKey:key];
NSLog(@"向iCloud查询是否已经购买值:key:%@, Value: %@", key, testString);
return testString;
}