How to use the sample session code "Basic Data with iCloud" 227 in WWDC 2012?

I am afraid for several weeks to solve this problem. so please help me solve this problem.

I downloaded the sample master data code with iCloud from apple WWDC 2012. and tried to use it for my application, but nothing worked.

Of course, I changed the code a bit ... but I don’t know exactly what I should do, and I can’t find any website that talks about this and the tutorials.

I spent several weeks and I'm tired. I know this is due to my lack of skills.

The problem I am facing is ...

- (void)asyncLoadPersistentStores { NSError *error = nil; if ([self loadLocalPersistentStore:&error]) { NSLog(@"Added local store"); } else { NSLog(@"Unable to add local persistent store: %@", error); } //if iCloud is available, add the persistent store //if iCloud is not available, or the add call fails, fallback to local storage BOOL useFallbackStore = NO; if ([self iCloudAvailable]) { if ([self loadiCloudStore:&error]) { NSLog(@"Added iCloud Store"); //check to see if we need to seed data from the seed store if (SEED_ICLOUD_STORE) { //deleted because SEED_ICLOUD_STORE value is false } //check to see if we need to seed or migrate data from the fallback store NSFileManager *fm = [[NSFileManager alloc] init]; if ([fm fileExistsAtPath:[[self fallbackStoreURL] path]]) { //migrate data from the fallback store to the iCloud store //there is no reason to do this synchronously since no other peer should have this data dispatch_queue_t globalQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(globalQueue, ^{ NSError *blockError = nil; BOOL seedSuccess = [self seedStore:_iCloudStore withPersistentStoreAtURL:[self fallbackStoreURL] error:&blockError]; if (seedSuccess) { NSLog(@"Successfully seeded iCloud Store from Fallback Store"); } else { NSLog(@"Error seeding iCloud Store from fallback store: %@", error); abort(); } }); } } else { NSLog(@"Unable to add iCloud store: %@", error); useFallbackStore = YES; } } else { useFallbackStore = YES; } if (useFallbackStore) { if ([self loadFallbackStore:&error]) { NSLog(@"Added fallback store: %@", self.fallbackStore); //you can seed the fallback store if you want to examine seeding performance without iCloud enabled //check to see if we need to seed data from the seed store if (SEED_ICLOUD_STORE) { //deleted } } else { NSLog(@"Unable to add fallback store: %@", error); abort(); } } } 

this is part of my source code from CoreDataController.m (session WWDC 2012 227) then the program stops when it calls the loadLocalPersistentStore method and I received this error message "Local storage not found in the package, this is most likely a build problem , make sure the repository file is copied as a package resource. "

I assume that the reason I got this is because I don't have a localStore.sqlite file and fallbackStore.sqlite, such as a sample. therefore he makes a mistake.

but although I skip this part (comment on it), I can’t connect iCloud, because now I got this error message "Unable to add iCloud storage: Error Domain = NSCocoaErrorDomain Code = 134100" The operation could not be completed. (Cocoa error 134100.) "UserInfo = 0x1dd93040 {metadata = {NSPsistenceFrameworkVersion = 419;"

I learned a lot about basic data from iCloud on iOS5, and it worked almost perfectly. but now I'm like a stupid person. I can not do anything. please help me.

strange thing: there is no code that entered the iCloud application identifier, the URL in the sample code from apple.

Thanks.

+1
source share
1 answer

I also had problems trying to implement the iCloud sample code from Apple WWDC 2012. I opened a ticket with support for Apple Developer, and their answer was November 15, 2012.

Several developers are having problems using iCloud and Core Data with this sample from WWDC. However, I have an updated SharedCoreData sample (enhanced from WWDC) which I think you should use instead. The CoreDataController object remains, but has been cleaned and improved. First I suggest running this sample, check to see if it syncs correctly between iOS devices. It is important to start first before proceeding with the changes. This way you get a good starting level. After you have confirmed that this works, go on to use the CoreDataController in your application.

He mentions that the CoreDataController class has changed. AppDelegate has also changed. New methods have been added, and now the code has become cleaner. I almost turned on my iCloud in my application, but still have a problem downloading the file initially. Trying to fix it now. Running the updated SharedCoreData application with pristine code works great! So this is a good place to start.

I don’t know how you will get this new code, except for opening a ticket with Apple Developer support (which is 50 bucks). The new project (still called SharedCoreData) is only 1 MB in size. I would like to email it to you if you wish.

I will post the update here when I figure out the original file upload solution for my application.

+5
source

Source: https://habr.com/ru/post/1379754/


All Articles