大佬教程收集整理的这篇文章主要介绍了iphone – NSInternalInconsistencyException(执行SQL字符串’INSERT INTO Y_UBMETA(YPEERID,YTRANSACTIONNUMBER)时出错),大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
由于未捕获的异常’NSInternalInconsistencyException’而终止应用程序,原因:’执行sql字符串时出错’INSERT INTO Y_UBMeta(YPEERID,YtransaCTIONnumbER)
未解决的错误错误域= NSCocoaErrorDomain代码= 134312“存储元数据恢复似乎已失败,请尝试再次将存储添加到协调器.如果不成功,请将数据迁移到新的无处不在的持久存储.” UserInfo = 0xdba5b80 {NSLocalizedDescription =存储元数据恢复似乎失败,请尝试再次将商店添加到协调器.如果不成功,请将数据迁移到新的泛素化持久性存储.},{
NSLocalizedDescription =“存储元数据恢复似乎已失败,请将数据迁移到新的无处不在的持久存储.”;
我该如何解决这个问题?因为它是iCloud的内部查询.我把我的代码块放在我写的方法之下.
- (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],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_; }
以上是大佬教程为你收集整理的iphone – NSInternalInconsistencyException(执行SQL字符串’INSERT INTO Y_UBMETA(YPEERID,YTRANSACTIONNUMBER)时出错)全部内容,希望文章能够帮你解决iphone – NSInternalInconsistencyException(执行SQL字符串’INSERT INTO Y_UBMETA(YPEERID,YTRANSACTIONNUMBER)时出错)所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。