Re: Mac core data and iCloud example app
Re: Mac core data and iCloud example app
- Subject: Re: Mac core data and iCloud example app
- From: Martin Hewitson <email@hidden>
- Date: Mon, 17 Oct 2011 07:27:27 +0200
Hi Marc,
In fact I am doing that. He's the options dictionary for the persistent store creation.
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
[dict setObject:[NSNumber numberWithBool:YES] forKey:NSMigratePersistentStoresAutomaticallyOption];
[dict setObject:@"<app_name>.store" forKey:NSPersistentStoreUbiquitousContentNameKey];
NSURL *contentURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:@"<TeamID>.<bundle_identifier>"];
[dict setObject:contentURL forKey:NSPersistentStoreUbiquitousContentURLKey];
(obviously with the <>'s filled in appropriately.)
Note, if I pass the bundle identifier to URLForUbiquityContainerIdentifier: as the WWDC video suggests, then I get nil for the contentURL. So in other words,
NSString *bundleId = [[NSApp mainBundle] bundleIdentifier];
NSURL *contentURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:bundleId];
then contentURL is nil. Perhaps this gives a clue what I've got configured wrongly?
Any other clues you can pass my way would be gratefully received,
Martin
On 17, Oct, 2011, at 04:33 AM, Marc Respass wrote:
>> Has anyone come across a sample app which demonstrates how to make a shoebox core data app which works with iCloud? I've dug into the documentation but I can't find any sample code. The "What's new in Core Data on Mac OS X" session from WWDC 2011 hints at some things but doesn't show any sample code. I think I've managed to get the app to register with iCloud by fighting with the provisioning profile stuff, but I don't see the app appearing in the iCloud preferences list of app (maybe it isn't supposed to?) but when I click on "Manage" then I see an app which has appeared but it's called "Unknown" and it has a fraction of the amount of data I'd expect. Then I tried the app on another machine and I get some notifications of type NSPersistentStoreDidImportUbiquitousContentChangesNotification together with lots of console messages starting with "_PFUbiquityRecordImportOperation processObjects:withState:withGlobalIDIndexesToLocalURIMap:andImportContext:outError" which seem to indicate some action has taken place. Now I'm stuck with what to do with these notifications. The WWDC sessions says one should use methods of the NSFilePresenter protocol, but I'm unsure how to go about this. Some sample code for the app shown in the WWDC session sure would help.
>
> Hi Martin,
>
> It sound like you did not include NSPersistentStoreUbiquitousContentNameKey as part of the options dictionary when creating your persistent store coordinator
>
> NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:uuid_string, NSPersistentStoreUbiquitousContentNameKey, nil];
> [persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
> configuration:nil
> URL:storeUrl
> options:nil
> error:&error])
>
> It's tricky to figure out exactly what to do. I found this Using Core Data with iCloud Release Notes under "Guidance for Library-style Applications".
>
> Hope this helps
> Marc_______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: email@hidden
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: email@hidden
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden