Skip to content

Latest commit

 

History

History
97 lines (60 loc) · 7.22 KB

2013-04-01-icloud.md

File metadata and controls

97 lines (60 loc) · 7.22 KB
layout title framework rating published description
post
iCloud
4.2
true
Perhaps what Apple is most renowned for is its consistent track record for creating great webservices. From consumer products like MobileMe and Ping to developer tools including the Provisioning Portal and iTunes Connect, Apple has continued to set new standards for convenience, robustness, and extensibility.

The Lisa. The Twentieth Anniversary Macintosh. The iPod Hi-Fi. The MacBook Wheel.

Each of these products exemplifies Apple's obsessive pursuit of quality as much as its unrivaled ability to anticipate the direction of things to come and execute flawlessly.

In the words of Wayne Gretzky: Skate where the puck's going, not where it's been.

But perhaps what Apple is most renowned for, however, is its consistent track record for creating great webservices. From consumer products like MobileMe and Ping to developer tools including the Provisioning Portal and iTunes Connect, Apple has continued to set new standards for convenience, robustness, and extensibility.

So when Apple introduced iCloud at WWDC in 2011, everyone in the audience was rapt in anticipation, overcome with a sense of optimistic wonder. "Not again!", we said to ourselves, shaking our head with a knowing smile. "This changes everything!"

And indeed, iCloud has changed everything. Although it seemed almost too good to be true when Steve Jobs got up on that stage in Moscone to announce iCloud to the world that morning in June—if anything, Apple has under-promised and over-delivered with iCloud.

Now, NSHipster usually covers obscure topics that you've probably never heard of. But this is one of those days where it just feels right to take this opportunity today to make sure we're all on the same page about iCloud.


iCloud is an umbrella term for the latest evolution of Apple's consumer webservices. Following from the success of iTools, .Mac, and MobileMe, iCloud manages our digital lives like never before, with features like Photo Stream, iTunes Match, and Documents in the Cloud.

What really ties everything together are the iCloud Storage APIs that allow developers to easily create applications to stay connected across all of your devices. These APIs come in three different flavors, depending on the particular needs of your application:

  • Key-value storage for discrete values, such as preferences, settings, and simple app state.
  • Document storage for user-visible file-based information such as word processing documents, drawings, and complex app state.
  • Core Data storage for shoebox-style apps and server-based, multi-device database solutions for structured content. iCloud Core Data storage is built on document storage and employs the same iCloud APIs.

Key-Value Storage... in the Cloud!

To store discrete values in iCloud for app preferences, app configuration, or app state, use iCloud key-value storage. Key-value storage is similar to the local user defaults database; but values that you place in key-value storage are available to every instance of your app on all of a user’s various devices.

Everyone knows that key-value storage is the secret to achieving Web Scale. That's just science.

Inject a healthy dose of Web Scale convenience into your app by incorporating NSUbiquitousKeyValueStore into your app:


- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  [[NSNotificationCenter defaultCenter]
      addObserver:self
         selector:@selector(ubiquitousKeyValueStoreDidChange:)
             name:NSUbiquitousKeyValueStoreDidChangeExternallyNotification
           object:[NSUbiquitousKeyValueStore defaultStore]];

  [[NSUbiquitousKeyValueStore defaultStore] synchronize];

  return YES;
}

Document Storage... in the Cloud!

Adopting iCloud document storage makes your app’s documents available on all of a user’s devices. Documents automatically implement most of the behavior expected of iCloud apps. Specifically, a document automatically ensures that local changes are safely coordinated with iCloud-originated changes.

Leave filesystem-based storage to those poor terrestrial bound souls who haven't been raptured to the iCloud. Dropbox? Never heard of 'em.

Having documents reside entirely in application-specific cloud containers means less clutter in your digital life. Why should other applications be able to access documents anyway? Why would I want to use any more than a single app for any particular task?

They say seeing is believing, but iCloud is built on faith—that everything will be there next time you open Pages, Keynote, or TextEdit. Leave the Finder to play with its folders and .DS_Store files; we shall inherit the open skies of digital freedom.

Core Data Storage... in the Cloud!

Adopting iCloud Core Data storage makes the content in a shoebox-style app (like iPhoto) or a database-style app (like Bento) available on all of a user’s devices. Each instance of your app, on each device attached to an iCloud account, maintains its own local Core Data store file. When data changes locally, Core Data writes change log files to your app’s default ubiquity container.

Developers really love Core Data syncing over iCloud. Seriously, they just can't stop raving about it.

Just when you thought Core Data couldn't get simpler, iCloud once again redefines our expectations.

Every time your application receives a NSPersistentStoreDidImportUbiquitousContentChangesNotification is reminiscent of that excitement of seeing the FedEx truck pull up with your pre-ordered iPhone 5. "This is the first day of the rest of my life", you'll think to yourself as you sign the proverbial confirmation slip of the package.

Sure, there's a chance that what you're signing is actually a repossession confirmation, and that the delivery guy will proceed to bust into your apartment and take everything you once owned, but at least you still have your new iPhone.

So it goes. Even an enlightened iLife is not without its risks.


Life just seems to float by, now that iCloud is managing our digital existence. No longer do we have to think about whether we have all of the information we need to go about our day:

From the moment our iPhone wakes us up with the "Marimba" ringtone, to our daily commute with Siri talking us through our day, and a productive work day using iWork; from the walk to the gym, listening to Podcasts.app, and working out with iTunes Sync, until our last waking hours as we wind down the day with Game Center, Apple and iCloud makes every day special.

And with the iCloud Storage APIs, you too can add your application to that perfect routine of digitally-synced bliss.

No foolin'.