由于未捕获的异常’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_; }解决方法 我遇到了同样的问题,之所以发生这种情况,是因为我已经从Xcode更改了datamodel的属性,而不是通过代码更改了我的app.我通过从iCloud删除sqlite文件解决了这个问题,并从设备中删除了应用程序然后重建.它对我有用. 总结
以上是内存溢出为你收集整理的iphone – NSInternalInconsistencyException(执行SQL字符串’INSERT INTO Y_UBMETA(YPEERID,YTRANSACTIONNUMBER)时出错)全部内容,希望文章能够帮你解决iphone – NSInternalInconsistencyException(执行SQL字符串’INSERT INTO Y_UBMETA(YPEERID,YTRANSACTIONNUMBER)时出错)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)