Just use NSUbiquitousKeyValueStore , which is very similar to NSUserDefaults , except that it is recorded in iCloud. You should read the iCloud Storage section of the Mac App Programming Guide, but what you need to do can be as simple as including the rights on the Summary tab of your app target in Xcode, and then do the following:
NSData *dataToStore = [NSKeyedArchiver dataWithRootObject:yourArray]; [[NSUbiquitousKeyValueStore defaultStore] setData:dataToStore forKey:@"yourKey"];
Then, to get your data, just do
NSData *retrievedData = [[NSUbiquitousKeyValueStore defaultStore] dataForKey:@"yourKey"]; NSArray *retrievedArray = [NSKeyedUnarchiver unarchiveObjectWithData:retrievedData];
It should be noted here that to work with an array of user objects, these objects must implement the NSCoding protocol. This is just a matter of implementing two methods; here is a good tutorial .
PS You use the same APIs that you are developing for OS X or iOS, so there is no reason why you couldnβt just follow the iOS tutorial for storing iCloud.
source share