http json 리소스 (범주 목록)에서 콘텐츠를 가져 와서 restkit 및 coredata와 연결하려고합니다.Restkit 0.20 + CoreData를 만들 수 없습니다
CoreData를 사용하지 않을 때 내 매핑이 사용되었습니다. 그럼 난 다음 자습서를 사용하기로 결정 그러나
http://www.alexedge.co.uk/portfolio/introduction-restkit-0-20/
를, 나는 이상한 오류가 발생하고 난 그냥 문이 안 열려는 이유를 알아 :
the entity (null) is not key value coding-compliant for the key "remoteId"
내 카테고리의 모델/개체가 매핑 된 remoteId있다 내 서버에있는 이드에게 문제가되지 않습니다.
- (NSFetchedResultsController *)fetchedResultsController{
if (!_fetchedResultsController) {
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass([Category class])];
fetchRequest.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]];
self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:[RKManagedObjectStore defaultStore].mainQueueManagedObjectContext sectionNameKeyPath:nil cacheName:@"Category"];
self.fetchedResultsController.delegate = self;
NSError *error;
[self.fetchedResultsController performFetch:&error];
NSLog(@"%@",[self.fetchedResultsController fetchedObjects]);
NSAssert(!error, @"Error performing fetch request: %@", error);
}
return _fetchedResultsController;
}
그리고 그러나, 오류에서이 Restkit 또는 CoreData이
이 요청 코드는 (그들이 널 실체 ??라고)하는 제가 이야기 실체 파악하지 못할 것 같다 매핑 :
+(void) prepareMapping {
RKObjectManager *manager = [RKObjectManager sharedManager];
NSDictionary *categoryAttributes = @{
@"id" : @"remoteId",
@"created_at" : @"updatedAt",
@"created_at" : @"createdAt",
@"name" : @"name",
@"ads_count": @"adsCount",
};
RKEntityMapping *categoryMapping = [RKEntityMapping mappingForEntityForName:@"Category" inManagedObjectStore:manager.managedObjectStore];
[categoryMapping addAttributeMappingsFromDictionary:categoryAttributes];
categoryMapping.identificationAttributes = @[@"remoteId"];
[manager addResponseDescriptorsFromArray:@[
[RKResponseDescriptor responseDescriptorWithMapping:categoryMapping
pathPattern:@"neighborhoods/:neighborhoodId/categories.json"
keyPath:@"index_categories.index_category"
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]
]];
}