RESTKIT 0.20 を使用していますが、マッピングに問題があります。誰がエラーがどこにあるのか教えてもらえますか? Thxと私のコードがあります:
RKObjectMapping* pageMapping = [RKEntityMapping mappingForEntityForName:@"Page" inManagedObjectStore:[RKManagedObjectStore defaultStore]];
[pageMapping addAttributeMappingsFromArray:@[ @"rows", @"columns" ]];
RKObjectMapping* magazineMapping = [RKEntityMapping mappingForEntityForName:@"Magazine" inManagedObjectStore:[RKManagedObjectStore defaultStore]];
[magazineMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"pages"
toKeyPath:@"pages"
withMapping:pageMapping]];
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:magazineMapping pathPattern:nil keyPath:@"magazine" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", kBasePath, [magazine contentPath]]];
NSURLRequest *r = [NSURLRequest requestWithURL:URL];
RKObjectRequestOperation *objectRequestOperation = [[RKObjectRequestOperation alloc] initWithRequest:r responseDescriptors:@[ responseDescriptor ]];
[objectRequestOperation setCompletionBlockWithSuccess:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
RKLogInfo(@"Load collection of Articles: %@", mappingResult.array);
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
RKLogError(@"Operation failed with error: %@", error);
}];
[objectRequestOperation start];
エンティティ マガジンがあります。
@interface Magazine : NSManagedObject
@property (strong) NSString * contentPath;
@property (strong) NSDate * date;
@property (strong) NSString * icon;
@property (strong) NSString * magazineID;
@property (strong) NSDecimalNumber * price;
@property (strong) id priceLocale;
@property (strong) NSString * title;
@property (strong) Page *pages;
そして最後に Page エンティティがあります:
@class Magazine;
@interface Page : NSManagedObject
@property (strong) NSString * content;
@property (strong) NSNumber * contentID;
@property (strong) NSNumber * columns;
@property (strong) NSNumber * rows;
@property (strong) NSString *pageID;
@property (strong) Magazine *assignedMagazine;
他の「ダウンロード」メソッドには問題がないため、エラーは Page エンティティのマッピングにあるはずです。