Questo è l'errore più strano. The internet suggerisce che si tratta di un problema con il targeting di Tiger; tranne che sto in realtà mira iOS 3 e 4.Dati principali: Store non può contenere istanze di entità (Errore cacao: 134020)
Error Domain=NSCocoaErrorDomain Code=134020 "The operation couldn\u2019t be completed. (Cocoa error 134020.)" UserInfo=0xc502350 {NSAffectedObjectsErrorKey=<PartRecommendation: 0x6a113e0> (entity: PartRecommendation; id: 0x6a0d0e0 <x-coredata:///PartRecommendation/tAE2B5BA2-44FD-4B62-95D7-5B86EBD6830014> ; data: {
"_rkManagedObjectSyncStatus" = 0;
name = "Thin canopy cover";
part = nil;
partRecommendationId = 6;
partType = "0x6a07f40 <x-coredata:///PartType/tAE2B5BA2-44FD-4B62-95D7-5B86EBD683003>";
}), NSUnderlyingException=Store <NSSQLCore: 0x5f3b4c0> cannot hold instances of entity (<NSEntityDescription: 0x6d2e5d0>) name PartRecommendation, managedObjectClassName PartRecommendation, renamingIdentifier PartRecommendation, isAbstract 0, superentity name PartOption, properties {
"_rkManagedObjectSyncStatus" = "(<NSAttributeDescription: 0x6d37550>), name _rkManagedObjectSyncStatus, isOptional 0, isTransient 0, entity PartRecommendation, renamingIdentifier _rkManagedObjectSyncStatus, validation predicates (\n), warnings (\n), versionHashModifier (null), attributeType 100 , attributeValueClassName NSNumber, defaultValue 0";
name = "(<NSAttributeDescription: 0x6d37c10>), name name, isOptional 1, isTransient 0, entity PartRecommendation, renamingIdentifier name, validation predicates (\n), warnings (\n), versionHashModifier (null), attributeType 700 , attributeValueClassName NSString, defaultValue (null)";
part = "(<NSRelationshipDescription: 0x6d2e660>), name part, isOptional 1, isTransient 0, entity PartRecommendation, renamingIdentifier part, validation predicates (\n), warnings (\n), versionHashModifier (null), destination entity Part, inverseRelationship recommendation, minCount 1, maxCount 1";
partRecommendationId = "(<NSAttributeDescription: 0x6d2e6d0>), name partRecommendationId, isOptional 1, isTransient 0, entity PartRecommendation, renamingIdentifier partRecommendationId, validation predicates (\n), warnings (\n), versionHashModifier (null), attributeType 100 , attributeValueClassName NSNumber, defaultValue 0";
partType = "(<NSRelationshipDescription: 0x6d2e720>), name partType, isOptional 1, isTransient 0, entity PartRecommendation, renamingIdentifier partType, validation predicates (\n), warnings (\n), versionHashModifier (null), destination entity PartType, inverseRelationship partRecommendations, minCount 1, maxCount 1";
}, subentities {
}, userInfo {
}, versionHashModifier (null)}
Sto aggiungendo un sacco di dati per Core Data prima che ottengo questo errore, ma io sto salvando due volte (una volta al centro, poi di nuovo alla fine). Tutto va bene dopo il primo salvataggio, è il secondo salvataggio a causare il problema, quindi posterò il codice che sto usando dopo il primo ma prima del secondo.
Landscape *landscape = [Landscape object];
Type *type = [Type object];
type.name = @"tree";
MeasurementType *caliperType = [MeasurementType object];
MeasurementType *heightType = [MeasurementType object];
InventoryTree *inventoryTree = [InventoryTree object];
inventoryTree.landscape = landscape;
inventoryTree.type = type;
Assessment *assessmentTree = [Assessment object];
assessmentTree.inventoryItem = inventoryTree;
assessmentTree.type = type;
[[inventoryTree mutableSetValueForKeyPath:@"assessments"] addObject:assessmentTree];
Measurement *caliper = [Measurement object];
Measurement *height = [Measurement object];
caliper.type = caliperType;
height.type = heightType;
[[assessmentTree mutableSetValueForKey:@"measurements"] addObjectsFromArray:[NSArray arrayWithObjects:caliper, height, nil]];
for (PartType *pType in [PartType allObjects]) {
pType.type = type;
Part *treePart = [Part object];
treePart.partType = pType;
[[assessmentTree mutableSetValueForKey:@"parts"] addObject:treePart];
for (PartCondition *cond in pType.partConditions) {
cond.partType = pType;
}
for (PartRecommendation *rec in pType.partRecommendations) {
rec.partType = pType;
}
}
I metodi di convenienza sto chiamando su sottoclassi NSManagedObject può essere trovato here.
Ho metodi altrove nell'app (molto tempo dopo questa esecuzione) che possono aggiungere/modificare/eliminare tutte le entità di cui sopra. L'errore non si verifica sulla stessa entità ogni volta.
Qualsiasi aiuto sarebbe molto apprezzato! Questo è difficile.
Grazie per avermi aiutato. Non sembra che possa aggiustarlo ma è successo. La mia unica ipotesi è che ci sia un bug nelle viscere dei Core Data a riguardo. – Andrew
L'uomo mi ha salvato così tanto tempo, ha funzionato perfettamente! – Shizam
Grazie per questo suggerimento! –