0

こんにちは、ネストされたRestkitエンティティマッピングの方法を教えてもらえますか? デバッグ中にエラーメッセージが表示され続けます。以下は私のエラーメッセージとコードです

[__NSSetM insertObject:atIndex:]: 認識されないセレクターがインスタンス 0x95269d0 に送信されました

コア データ ファミリー エンティティ

コア データの子エンティティ

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
4

1 に答える 1

5

私はすでに自分の間違いに気づきました。[familyMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"Child" toKeyPath:@"child" withMapping:childMapping]]; toKeyPath 文字列は小文字で割り当てる必要があります。「コアデータ関係文字列に従ってください」。

于 2012-12-08T15:39:57.593 に答える