2012-12-08 16 views
0

안녕하세요, 저는 중첩 된 Restkit 엔티티 매핑을 수행하는 방법을 가르쳐 주실 수 있습니까? 내가 디버그, 아래RestKit 엔티티 매핑

[__NSSetM insertObject:atIndex:] 내 오류 메시지와 코드 동안 오류 메시지가 계속 : 인식 할 수없는 선택기 인스턴스에 전송 0x95269d0

Core Data Family Entity

Core Data Child Entity

JSON 데이터가

Family =(
     { 
     id = "1"; 
     parentName = "Mr John"; 
     Child =(
       { 
       parentID = "1"; 
       childName = "James"; 
       age = "18"; 

      }, 
      { 
       parentID = "1"; 
       childName = "ruby"; 
       age = "19"; 
           }, 
          { 
       parentID = "1"; 
       childName = "ella"; 
       age = "20"; 
      } 
     ); 
    } 
); 

내 AppDelegate.m

RKEntityMapping *familyMapping = [RKEntityMapping mappingForEntityForName:@"Family" inManagedObjectStore:managedObjectStore]; 
debtorMapping.identificationAttributes = @[ @"id" ]; 

[familyMapping addAttributeMappingsFromDictionary:@{ 
@"id": @"accNo", 
@"parentName": @"companyName" 
}]; 


RKEntityMapping *childMapping = [RKEntityMapping mappingForEntityForName:@"Child" inManagedObjectStore:managedObjectStore]; 

childMapping.identificationAttributes = @[ @"parentID"]; 

[childMapping addAttributeMappingsFromDictionary:@{ 
@"parentID": @"parentID", 
@"childName": @"childName", 
@"age": @"age" 
}]; 


[familyMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"Child" toKeyPath:@"Child" withMapping:childMapping]]; 


RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:familyMapping 
                        pathPattern:nil 
                         keyPath:@"Family" 
                        statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)]; 


[objectManager addResponseDescriptor:responseDescriptor]; 

가족 NSManagedObject

@class Child; 
@interface Family : NSManagedObject 
@property (nonatomic, retain) NSString * id; 
@property (nonatomic, retain) NSString * parentName; 
@property (nonatomic, retain) NSSet *child; 
@end 
@interface Family (CoreDataGeneratedAccessors) 
- (void)addChildObject:(Child *)value; 
- (void)removeChildObject:(Child *)value; 
- (void)addChild:(NSSet *)values; 
- (void)removeChild:(NSSet *)values; 
@end 

아이 NSManageObject

@class Family; 
@interface Child : NSManagedObject 
@property (nonatomic, retain) NSString * parentID; 
@property (nonatomic, retain) NSString * childName; 
@property (nonatomic, retain) NSString * age; 
@property (nonatomic, retain) Family *family; 
@end 

답변

5

난 이미 내 실수를 발견했다. [familyMapping addPropertyMapping : [RKRelationshipMapping relationshipMappingFromKeyPath : @ "Child"toKeyPath : @ "child"withMapping : childMapping]]; toKeyPath 문자열은 작은 문자로 지정해야합니다. "핵심 데이터 관계 문자열을 따르십시오".