Lecture 17

Lecture 17 - Stanford CS193p Developing Applications for...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Stanford CS193p Fall 2011 Developing Applications for iOS Fall 2011 Stanford CS193p
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Stanford CS193p Fall 2011 To day iCloud Sharing documents among a user’s devices
Background image of page 2
Stanford CS193p Fall 2011 iCloud Fundamentally: nothing more than a URL of a shared directory However, since it is over the network, there are lots of things to consider. Most importantly, latency and the rami±cations of shared access. Entitlements In order for your application to access the cloud, you must set up its entitlements. Luckily this is a single button click in Xcode:
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Stanford CS193p Fall 2011 iCloud The URL Assuming you just have one container in your Entitlements . .. [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]; Usually you put your documents in the @“Documents” directory (special) inside this URL. NSFileManager You can use it, but you don’t want to use it in the main thread (it’s happening over the network). Don’t use it to enumerate the contents of directories (need an always-updating query for that). And you also will want to “coordinate” any ±le operations with other devices. Coordination happens among NSFilePresenter s using the NSFileCoordinator class. NSFilePresenter This class is an abstraction for something that “presents” the data of a ±le/directory to the user. Your presenter would get involved whenever a coordinated change to the ±le/directory occurs. Not going to cover NSFilePresenter ’s API in this class. Instead, we’ll talk about UIManagedDocument (which is an NSFilePresenter ).
Background image of page 4
Stanford CS193p Fall 2011 iCloud UIDocument An NSFilePresenter . Abstraction for a document. Automatically coordinates changes to the document. Primary methods you’d override would be . .. - (id)contentsForType:(NSString *)type error:(NSError **)error; - (BOOL)loadFromContents:(id)contents ofType:(NSString *)type error:(NSError **)error; If your data is stored in a Core Data database, though, you’d use UIManagedDocument . UIManagedDocument Fully iCloud capable. You need only sign up for the appropriate noti±cations to keep your UI in sync. Put your UIManagedDocument s into the Documents directory in iCloud. iCloudDocumentsURL = [iCloudURL URLByAppendingPathComponent:@“Documents”];
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Stanford CS193p Fall 2011 iCloud Only UIManagedDocument changes should be synced to iCloud Uploading only a log of changes is a lot better performing than uploading the whole database! To get this, you must set your document’s
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 17

Lecture 17 - Stanford CS193p Developing Applications for...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online