2013-02-21 3 views
0

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)] 
     ]]; 
    } 

답변

1

NSStringFromClass([Category class])이 작동하는지 잘 모릅니다. 다음 코드를 사용해 보셨습니까?

NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Category"]; 

또한 당신은 일을 진행하는 방법을 확인하기 위해 RestKit v.020-RC1 zip 파일의 내부 예를 들어, 핵심 데이터 프로젝트를 확인할 수 있습니다.

관련 문제