I m using RestKit to grab objects from my RoR service and using CoreData to persist some of the objects (more static-type lookup table objects). TasteTag is one of those persisted objects:
#ifdef RESTKIT_GENERATE_SEED_DB
NSString *seedDatabaseName = nil;
NSString *databaseName = RKDefaultSeedDatabaseFileName;
#else
NSString *seedDatabaseName = RKDefaultSeedDatabaseFileName;
NSString *databaseName = @"Model.sqlite";
#endif
RKObjectManager* manager = [RKObjectManager objectManagerWithBaseURL:kServerURL];
manager.objectStore = [RKManagedObjectStore objectStoreWithStoreFilename:databaseName usingSeedDatabaseName:seedDatabaseName managedObjectModel:nil delegate:self];
.. lots of fun object mapping ..
RKManagedObjectMapping* tasteTagMapping = [RKManagedObjectMapping mappingForClass:[TasteTag class]];
[tasteTagMapping mapKeyPath:@"id" toAttribute:@"tasteTagID"];
[tasteTagMapping mapKeyPath:@"name" toAttribute:@"name"];
tasteTagMapping.primaryKeyAttribute = @"tasteTagID";
[[RKObjectManager sharedManager].mappingProvider setMapping:tasteTagMapping forKeyPath:@"taste_tags"];
[[RKObjectManager sharedManager].mappingProvider addObjectMapping:tasteTagMapping];
.. some more mapping ..
I have the data coming back from the RoR server and it s getting mapped to objects as expected. The Core Data entity also seems mapped fine after RestKit gets the request back:
"<TasteTag: 0x6e87170> (entity: TasteTag; id: 0x6e85d60 <x-coredata://03E4A20A-21F2-4A2D-92B4-C4424893D559/TasteTag/p5> ; data: <fault>)"
问题是,当我试图在物体上获取财产时,过错似乎会发生火灾。 首先,我只是说,这些财产总是回落为零(即使这会造成过失):
for (TasteTag *tag in self.vintage.tasteTags) {
[tagNames addObject:tag.name]; //get error of trying to add nil to array
}
http://www.mlsite.net/blog/?p=518"。 我试图打上<条码>[标注将AccessValueForKey:nil],结果如下:
Terminating app due to uncaught exception NSObjectInaccessibleException , reason: CoreData could not fulfill a fault for 0x6e7b060 <x-coredata://03E4A20A-21F2-4A2D-92B4-C4424893D559/TasteTag/p5>
根据关键因素(Tasteg/p5)对实体进行盘点,确实显示它符合我的期望。
与Resit有关的其他员额建议取消目标海滩(我不使用该物体),因为通常由实体删除。 但在这个阶段,我只是读,而不是删除,我没有切身之处。
如果我只打电话[TasteTag allObjects]
I m 能够收回所有物体的罚款,并且无问题装载。 在他们被错过的情况下,似乎只是这样。