0

我已经使用了用于不同实体映射的通用 RKObjectManager,如下面的鳕鱼,但是当我尝试为特定实体进行映射时不能,因为我有两个具有相同 keyPath 的实体,这是我怎么能想到的问题。

   // Search  mapping ...
RKEntityMapping *searchEntityMapping = [RKEntityMapping mappingForEntityForName:NSStringFromClass([ABB class]) inManagedObjectStore: aBBManager.managedObjectStore];

[searchInfoEntityMapping addAttributeMappingsFromDictionary:@{
 @"count" : @"count",
 @"total_count" : @"totalCount",

 }];


 // Search Advanced  mapping ...
RKEntityMapping *searchAdvEntityMapping = [RKEntityMapping mappingForEntityForName:NSStringFromClass([ABB class]) inManagedObjectStore: aBBManager.managedObjectStore];

[searchAdvEntityMapping addAttributeMappingsFromDictionary:@{
 @"count" : @"count",
 @"data" : @"dataCount",

 }];

// Search  Descriptor
RKResponseDescriptor *aBBResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:searchEntityMapping pathPattern:nil keyPath:@"locations" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];


 // Search Adv Descriptor
 RKResponseDescriptor *aBB2ResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:searchAdvEntityMapping pathPattern:nil keyPath:@"locations" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
4

1 回答 1

3

您应该使用该pathPattern参数来允许 RestKit 在您发出特定请求时知道使用哪个响应描述符(因为您应该在不同实体的 URL 中使用不同的路径)。

如果由于某种原因您不能,则需要为RKObjectManager您提出的每个不同请求创建多个实例并使用适当的实例。

于 2013-10-28T13:18:25.167 回答