问题
I'm strugling few weeks to solve this problem.. so please help me out to solve this problem.
I downloaded the sample code of core data with iCloud from apple WWDC 2012. and tried to use it for my application but nothing worked.
of course, I changed some code little bit.. but I don't know exactly what I should do and can't find any website that saying about it and tutorials..
I spended few weeks already and I'm tired. I know this is because of my lack of skill.
problem I'm 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 (WWDC 2012 session 227) then, program stopped when it calls "loadLocalPersistentStore" method and I got this error message "Local store not found in bundle, this is likely a build issue, make sure the store file is being copied as a bundle resource."
I guess the reason why I got this is that I don't have localStore.sqlite and fallbackStore.sqlite file like the sample. so It makes error.
but although I skip that part(comment it), can't connect iCloud because now I got this error message "Unable to add iCloud store: Error Domain=NSCocoaErrorDomain Code=134100 "The operation couldn’t be completed. (Cocoa error 134100.)" UserInfo=0x1dd93040 {metadata={ NSPersistenceFrameworkVersion = 419;"
I learned many things about core data with iCloud on iOS5 and It worked almost perfectly. but now I'm like a stupid person. there is nothing I can do. please help me out.
strange thing is there is no code that typed about iCloud app ID, url something in sample code from apple.
Thanks.