Wednesday, 19 June 2013

How to Check iCloud is available in your app?

After enabling icloud on your app, just copy and paste the highlighted lines of code to your appdelegate.m to check that icloud is available for your app:

- (void)initializeiCloudAccess {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        if ([[NSFileManager defaultManager]
             URLForUbiquityContainerIdentifier:nil] != nil)
            NSLog(@"iCloud is available\n");
        else
            NSLog(@"iCloud is not available.\n");
    });
}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   
    [self initializeiCloudAccess];

    return YES;
}

No comments:

Post a Comment