Simple iCloud implementation

2019-06-06 18:31发布

问题:

I have created a new appID and enabled iCloud on iTunes Connect. I have enabled entitlements within the app from the summary section. I have included this code for checking for iCloud availability:

NSURL *ubiq = [[NSFileManager defaultManager] 
                   URLForUbiquityContainerIdentifier:nil];
    if (ubiq) {
        NSLog(@"iCloud access at %@", ubiq);
        // TODO: Load document... 
    } else {
        NSLog(@"No iCloud access");
    }

All I need to do is a method to save an NSArray to the cloud and one to be able to download it. Yet, I'm having a hard time wading through the docs to figure out exactly what they should look like. Thanks for the help!!

回答1:

Have a look at iCloud basics and code sample

It basically shows you a working example - something which is missing from the Apple docs. Nonetheless, the docs are really good as pointed out by Hubert, so it's not a replacement. It just get's you started and will get you interested in reading the docs.



回答2:

Yes, the Doc's are the place to learn this. Or better yet watch the Stanford University iTunes U lectures. The fall 2011 has all new iOS 5 lectures including lectures on iCloud. You can now download the new iTunes-University app and get it that way also. These courses are taught by some of the best professors in the world and are clear, concise and jam packed with knowledge on an array of iOS subjects.