Map url parameters to objects using RESTKit

后端 未结 2 1993
轮回少年
轮回少年 2020-12-10 06:07

is there a way to map the parameters in an URL to the results?

I got a rest service where the user can search something by its ID. The path is search/:id

2条回答
  •  佛祖请我去吃肉
    2020-12-10 06:44

    You probably need to specify the pathPattern and keyPath of your response descriptor::

    RKResponseDescriptor *responseDescriptor =
      [RKResponseDescriptor
       responseDescriptorWithMapping:itemMapping
       method:RKRequestMethodAny
       pathPattern:@"search/:id"
       keyPath:@"item"
       statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
    

提交回复
热议问题