2012-07-07 10 views
8

のiOSのiCloudNSInternalInconsistencyException(SQL文字列の実行中にエラー 'INSERT INTO Y_UBMETA(YPEERID、YTRANSACTIONNUMBER))

キャッチされない例外によりにアプリを終了 'NSInternalInconsistencyException'、理由:' SQL文字列の実行中にエラー「INSERT INTO Y_UBMETA (YPEERID、YTRANSACTIONNUMBER)

未解決のエラーエラードメイン= NSCocoaErrorDomainコード= 134312 "ストアのメタデータの回復に失敗したようですが、再度コーディネーターにストアを追加してみてください。格納。" UserInfo = 0xdba5b80 {NSLocalizedDescription =メタデータリカバリの保存に失敗しました。ストアをコーディネータに再度追加してみてください。それが失敗した場合は、データを新しいユビキタス永続ストアに移行してください。}、{ NSLocalizedDescription = "ストアのメタデータリカバリが失敗したようですが、再度コーディネータにストアを追加してみてください。新しいユビキタス永続ストア "

この問題を解決するにはどうすればよいですか?それがiCloudの内部クエリであることを確認します私がいないコードで私のアプリから、Xcodeのからのデータモデルの属性を変更しているので、私は、私は同じ問題を持っている

- (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_; 
} 

答えて

0

..私が書かれている方法の下に私のコードブロックを入れています、それは起こりました。私はiCloudからSQLiteファイルを削除し、アプリをデバイスから削除して再構築することでこれを解決しました。それは私のために働いた。

関連する問題