Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RKResponseDescriptor in RESTKit is Deprecated

I'm trying to do some RESTKit http requests, and when I use the RKResponseDescriptor line of code, it says 'responseDescriptorWithMapping:pathPattern:keyPath:statusCodes:' is deprecated.

Here is how I coded it:

RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor 
responseDescriptorWithMapping:mapping pathPattern:nil keyPath:nil 
statusCodes:statusCodeSet];

What exactly is the deal here, and how can I fix it?

like image 470
comrod Avatar asked Aug 01 '13 03:08

comrod


2 Answers

Restkit 0.20.3 introduced new feature that allows you to use a response descriptor with multiple requests methods

+ (instancetype)responseDescriptorWithMapping:(RKMapping *)mapping
                                   method:(RKRequestMethod)method
                              pathPattern:(NSString *)pathPattern
                                  keyPath:(NSString *)keyPath
                              statusCodes:(NSIndexSet *)statusCodes

So you can just switch to this new implementation.

like image 140
Dmitry Shevchenko Avatar answered Nov 03 '22 06:11

Dmitry Shevchenko


I had to search a fair bit to figure out what to put for method, so I thought I would share the specifics for others:

RKResponseDescriptor *responseDescriptor =
  [RKResponseDescriptor responseDescriptorWithMapping:mapping
                                               method:RKRequestMethodAny
                                          pathPattern:nil keyPath:nil
                                          statusCodes:statusCodeSet];

I used the general RKRequestMethodAny, but you can use something more specific if you prefer.

like image 30
Nico teWinkel Avatar answered Nov 03 '22 07:11

Nico teWinkel