iCloud Storage APIs 使用 Updated

// 传nil获取iCloud容器(iCloud Container)列表中的第一个容器
NSURL *iCloudURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
NSLog(@"%@", [iCloudURL absoluteString]);

NSUbiquitousKeyValueStore *cloudStore = [NSUbiquitousKeyValueStore defaultStore];
[cloudStore setString:[iCloudURL absoluteString] forKey:@"iCloudURL"];//保存一个键值,不同的数据类型有不同的set方法
[cloudStore synchronize]; // 保存,相当于数据库的commit
NSLog(@"%@",[cloudStore stringForKey:@"iCloudURL"]);

[cloudStore removeObjectForKey:@"iCloudURL"];//删除一个键值,remove方法就只有这一个,不用区分数据类型
NSLog(@"%@",[cloudStore stringForKey:@"iCloudURL"]);//获取一个键的值,需要区分数据类型
声明: 本文采用 BY-NC-SA 协议进行授权. 转载请注明转自: iCloud Storage APIs 使用 http://www.ohbug.com/view/34

AD

Photo Stream

运行状态

运行时间 379D
文章数 20