Intro to cloud kit Cocoader.org 24 July 2014

Preview:

DESCRIPTION

CocoaCoder (CocoaHeads Austin) presentation on Apple's new CloudKit APIs in iOS8 and OS X Yosemite

Citation preview

INTRO TO APPLE’S CLOUDKITCOCOACODER.ORG MEETUP 24 JULY 2014 CARL BROWN (@CARLBRWN)

DisclaimerWe’ve only known of these features for about a month

I’ve yet to ship a project with it

Everything you are about to see is in Beta and Subject to Change

*image: http://vectorgoods.com/wp-content/uploads/2012/01/nuclear-danger-vector.jpg

Event InteractivityPlease(!) stop me if you have questions

http://farm3.static.flickr.com/2197/2200500024_e93db99b61.jpg

What is CloudKit? (short version)Apple’s competitor to Facebook’s Parse

(And Google App Engine, and Heroku and etc etc)

(And to some Extent Dropbox)

It’s a way for Apps’ users to share information between them without the need for a separate server

Is it Going to Work this time?Apple is dog-fooding this Big time

We’re told that iCloud Drive and the new iCloud Photo Library are built on it

Much more adoption inside Apple than 2012’s iCloud<->CoreData syncing

Is that enough? Only time will tell.

So what can I use this for?Providing information and assets to all users (and instances) of your app

Providing search and update for data your app

What can’t I use this for?As far as I can tell, there’s no “group” mechanism or per-user ACLs

So no “sharing with friends” apps with non-public information

You can “hide” info within your app’s code by refusing to search on it, but I don’t know that I’d trust it for sensitive data

No Server-Side CodeEverything has to be done in-app

No bulk-import mechanism I can find

But should work for simple apps

Containers

Overhead object that differentiates between different apps in server-land

Usually 1 container per application

some limited support for multiple apps talking to one container

Your app has a defaultContainer

DatabasesPublic and Private databases within a container

One private database per iCloud user of the App

private databases read/write for the user. Available to app only when user is logged in

Public database is query-able by all users of your app

Recordskey/value pairs with Record Types

Basic PList-type values + Location + Assets + Arrays

Not necessary to define a schema first

Metadata (who, what, when, some versioning)

Record ZonesGroups of Records of particular types

Used for segregating updates

ReferencesRelationships between Records

Deletes can get complicated, though

AssetsLarge binary data

Pictures, Presentations, Documents, etc

Tied to a Record

Garbage Collected when Record deleted

Efficiently uploaded/downloaded

Querieslookup by recordID

lookup via NSPredicate (or a subset thereof)

SubscriptionsA way to be notified when records matching a query are added or modified

Automatically generates a push notification

Saves you from having to poll

Asynchronous APIAll NSOperation-based

Priorities, dependencies, completion blocks

Atomic CommitsFor records and relationships

Delta DownloadsAble to retrieve all transactions that occurred since last fetch

You can use this to implement an offline cache

But no caching is built-in

Notification CollectionsReceive groups of notifications since a given point

Call on push notification response

Push notifications can get consolidated

Conflict ResolutionOn conflicts, you’ll be presented with the old record, your new record and the server’s conflicting record.

You’ll need to resolve the conflict yourself

You’ll then need to update the server with a new transaction ID

Ability to force-override if you have to

Limited support for schema changesMostly of the “adding a new field on the new version” variety

Custom DashboardAllows you to create static groups for “Admin” access type functions

More InformationSession 208 - Introducing CloudKit

Session 231 - Advanced CloudKit