在对象管理器中映射RKPaginator请求中的路径参数

时间:2016-01-29 14:23:22

标签: restkit

如果不是RKPaginator请求,我可以使用以下代码正确映射路径参数。

RKEntityMapping *mapping = [RKEntityMapping mappingForEntityForName:className inManagedObjectStore:[RKManagedObjectStore defaultStore]];
[mapping setIdentificationAttributes:@[@"id"]];
[mapping addAttributeMappingsFromDictionary:@{
    @"@metadata.routing.parameters.id": @"entityId",
    @"@metadata.mapping.collectionIndex": @"itemIndex",
    .... other mapping attributes
}];

RKResponseDescriptor* learningObjRd = [RKResponseDescriptor responseDescriptorWithMapping:mapping 
    method:RKRequestMethodGET pathPattern:@"entity/:entityId" keyPath:@"objects" 
    statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];

[self.objectManager.router.routeSet addRoute:
    [RKRoute routeWithName:@"learningObjects" pathPattern:@"entity/:id" method:RKRequestMethodGET]];
[self.objectManager getObjectsAtPathForRouteNamed:@"learningObjects" object:@{@"id":entityId} 
    parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {}];

使用RKPaginator时,我找不到添加命名路由的方法。所以我用户url创建paginator

RKPaginator* paginator = [self.objectManager paginatorWithPathPattern:@"series?page=:currentPage&count=:perPage" 
    parameters:nil];
[paginator loadPage:1];

有没有办法在URL中指定哪些参数也可用于映射?

0 个答案:

没有答案
相关问题