iOS干货

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;
}

2. iCould Documents:

iOS: iCloud开发案例

3.iCloud CloudKit(待补充)

上一篇下一篇

猜你喜欢

热点阅读