我使用了常用的RKObjectManager用于不同的实体映射,如下面的cod,但是当我尝试为特定实体制作映射时,因为我有两个具有相同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)];
答案 0 :(得分:3)
您应该使用pathPattern
参数来允许RestKit知道在您发出特定请求时要使用的响应描述符(因为您应该在不同实体的URL中使用不同的路径)。
如果出于某种原因,您无法创建RKObjectManager
的多个实例,并为您提出的每个不同请求使用相应的实例。