Kończenie aplikację spowodowane nieprzechwyconego wyjątku 'NSInternalInconsistencyException', przyczyna:' Błąd podczas wykonywania programu SQL ciąg „INSERT INTO Y_UBMETA (YPEERID, YTRANSACTIONNUMBER)
Nierozwiązane error Domain = kod NSCocoaErrorDomain = 134312 „odzysk metadanych Store wydaje się nie udało, spróbuj ponownie dodając sklepu koordynatora. Jeśli to się nie powiedzie, migrację danych do nowego ubiquitized trwałe sklep." UserInfo = 0xdba5b80 {NSLocalizedDescription = Zapisywanie odzyskiwania metadanych wydaje się nieudane, spróbuj ponownie dodać sklep do koordynatora. Jeśli to się nie uda, zmodyfikuj dane do nowego, powszechnie stosowanego magazynu trwałego.}, { NSLocalizedDescription = "Zapisywanie odtwarzania metadanych wydaje się nieudane, spróbuj ponownie dodać sklep do koordynatora. Jeśli to się nie powiedzie, zmodyfikuj dane do nowy wszechobecny sklep internetowy. ";
Jak rozwiązać ten problem? Coz, że jest to wewnętrzna kwerenda dla iCloud. Kładę mój blok kodu poniżej metody Pisałem ..
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
NSLog(@"persistentStoreCoordinator:%@",[persistentStoreCoordinator_ description]);
if((persistentStoreCoordinator_ != nil))
{
return persistentStoreCoordinator_;
}
NSLog(@"persistentStoreCoordinator:%@",[persistentStoreCoordinator_ description]);
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"CoreDataModel.sqlite"];
persistentStoreCoordinator_ = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
NSPersistentStoreCoordinator* psc = persistentStoreCoordinator_;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSFileManager *fileManager = [NSFileManager defaultManager];
// Migrate datamodel
NSDictionary *options = nil;
// this needs to match the entitlements and provisioning profile
NSURL *cloudURL = [fileManager URLForUbiquityContainerIdentifier:nil];
NSLog(@"cloudURL:%@",cloudURL);
//NSString* coreDataCloudContent = [[cloudURL path] stringByAppendingPathComponent:@"Data"];
cloudURL = [cloudURL URLByAppendingPathComponent:@"Data"];
// NSLog(@"coreDataCloudContent:%@",coreDataCloudContent);
//if ([coreDataCloudContent length] != 0 && [[defaults objectForKey:@"allMetadataFlag"] isEqualToString:@"YES"])
if (cloudURL)//&& [[defaults objectForKey:@"allMetadataFlag"] isEqualToString:@"YES"])
{
// iCloud is available
// cloudURL = [NSURL fileURLWithPath:coreDataCloudContent];
NSLog(@"cloudURL:%@",cloudURL);
options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption,
@"SecureAssistant.store", NSPersistentStoreUbiquitousContentNameKey,
cloudURL, NSPersistentStoreUbiquitousContentURLKey,nil];
}
else
{
// iCloud is not available
options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption,nil];
}
NSError *error = nil;
[psc lock];
if (![psc addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error])
{
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
[psc unlock];
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"asynchronously added persistent store!");
[[NSNotificationCenter defaultCenter] postNotificationName:@"RefetchAllDatabaseData" object:self userInfo:nil];
});
});
return persistentStoreCoordinator_;
}