A class that simplifies working with iCloud.
Switch branches/tags
Nothing to show
Clone or download
drewmccormack Cleaned up the directory contents method. Removed ICADirectory class,…
… and exposed the ICACloudFile class, but updated it, and included fileAttributes.
Latest commit c28d3f8 Jan 21, 2014
Failed to load latest commit information.
ICACloud.h Cleaned up the directory contents method. Removed ICADirectory class,… Jan 21, 2014


iCloud Access

Author: Drew McCormack
Created: 18th January, 2014
Last Updated: 18th January, 2014

iCloud Access is a simple class that makes it easier to work with iCloud, hiding details such as file coordination and metadata queries. It is much more like accessing a web service with a Cocoa networking class, which most developers are more used to.

The class was originally developed as part of the Ensembles Core Data Sync framework, and has been extracted for easier integration in projects not using Ensembles.


Just drag the ICACloud.h and ICACloud.m files directly into your Mac or iOS Xcode project.

Using ICACloud

The methods of the class are fairly self explanatory, mirroring NSFileManager to some extent. One big difference is that most are asynchronous, with a completion callback block. The completion block includes an error parameter, which should be checked. If it is nil, the operation was successful, and if an NSError is supplied, it failed.

Cloud paths are relative to the ubiquity container, but you can optionally supply a relative path to a root directory in the container. This directory, and intermediate directories, will be created automatically if they don't exist.

You should check the isConnected property to make sure the user is logged into iCloud before using the class.

Here is a simple example of using the ICACloud class.

ICACloud *cloud = [[ICACloud alloc] initWithUbiquityContainerIdentifier:@"XXXXXXXXXX.com.mycompany.cloudtest"
if (cloud.isConnected) {
    [cloud createDirectoryAtPath:@"Subdirectory" completion:^(NSError *error) {
        if (error) {
          NSLog(@"Failed to create subdirectory");
        [cloud uploadLocalFile:@"/Users/me/Downloads/LocalImage.png" 
          completion:^(NSError *error) {
          if (error) NSLog(@"Failed to upload: %@", error);