Intro to cloud kit Cocoader.org 24 July 2014

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

description

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

Transcript of Intro to cloud kit Cocoader.org 24 July 2014

Page 1: Intro to cloud kit   Cocoader.org 24 July 2014

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

Page 2: Intro to cloud kit   Cocoader.org 24 July 2014

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

Page 3: Intro to cloud kit   Cocoader.org 24 July 2014

Event InteractivityPlease(!) stop me if you have questions

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

Page 4: Intro to cloud kit   Cocoader.org 24 July 2014

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

Page 5: Intro to cloud kit   Cocoader.org 24 July 2014

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.

Page 6: Intro to cloud kit   Cocoader.org 24 July 2014

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

Page 7: Intro to cloud kit   Cocoader.org 24 July 2014

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

Page 8: Intro to cloud kit   Cocoader.org 24 July 2014

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

No bulk-import mechanism I can find

But should work for simple apps

Page 9: Intro to cloud kit   Cocoader.org 24 July 2014

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

Page 10: Intro to cloud kit   Cocoader.org 24 July 2014

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

Page 11: Intro to cloud kit   Cocoader.org 24 July 2014

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)

Page 12: Intro to cloud kit   Cocoader.org 24 July 2014

Record ZonesGroups of Records of particular types

Used for segregating updates

Page 13: Intro to cloud kit   Cocoader.org 24 July 2014

ReferencesRelationships between Records

Deletes can get complicated, though

Page 14: Intro to cloud kit   Cocoader.org 24 July 2014

AssetsLarge binary data

Pictures, Presentations, Documents, etc

Tied to a Record

Garbage Collected when Record deleted

Efficiently uploaded/downloaded

Page 15: Intro to cloud kit   Cocoader.org 24 July 2014

Querieslookup by recordID

lookup via NSPredicate (or a subset thereof)

Page 16: Intro to cloud kit   Cocoader.org 24 July 2014

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

Page 17: Intro to cloud kit   Cocoader.org 24 July 2014

Asynchronous APIAll NSOperation-based

Priorities, dependencies, completion blocks

Page 18: Intro to cloud kit   Cocoader.org 24 July 2014

Atomic CommitsFor records and relationships

Page 19: Intro to cloud kit   Cocoader.org 24 July 2014

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

Page 20: Intro to cloud kit   Cocoader.org 24 July 2014

Notification CollectionsReceive groups of notifications since a given point

Call on push notification response

Push notifications can get consolidated

Page 21: Intro to cloud kit   Cocoader.org 24 July 2014

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

Page 22: Intro to cloud kit   Cocoader.org 24 July 2014

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

Page 23: Intro to cloud kit   Cocoader.org 24 July 2014

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

Page 24: Intro to cloud kit   Cocoader.org 24 July 2014

More InformationSession 208 - Introducing CloudKit

Session 231 - Advanced CloudKit