restkit - How do I implement dynamic mapping (RKDynamicMapping) with this JSON? -


my backend returns kind of json files:

{ "response": { "message": "test" }, "responsecode": 205 }

depending on responsecode value, inside response different. know have use rkdynamicmapping, not sure how. problem see in sample code , manual, attribute differentiate among mappings inside, in case outside. tried doesn't work:

    [dynamicmapping setobjectmappingforrepresentationblock:^rkobjectmapping *(id representation) {         nsnumber* responsecode=(nsnumber*)representation[@"responsecode"];         if (responsecode.integervalue==204) {             return searchbylocatorresponsecontent204mapping;         } else if (responsecode.integervalue==205) {             return searchbylocatorresponsecontent205mapping;         }         return nil;     }];     rkresponsedescriptor *searchbylocatorresponsecontentresponsedescriptor = [rkresponsedescriptor responsedescriptorwithmapping:dynamicmapping pathpattern:kcheckinsearchbylocatorpath keypath:nil  statuscodes:rkstatuscodeindexsetforclass(rkstatuscodeclasssuccessful)];     [objectmanager addresponsedescriptor:searchbylocatorresponsecontentresponsedescriptor]; 

i guess because mapping want change doesn't containt attribute distinguish them (like type in girls/boys sample code rest kit website)

does have recommendation? in advance.

if set this, restkit expects dynamicmapping provide mapping whole response json, not contents of 'response'.

basically searchbylocatorresponsecontent204mapping needs have mapping response field , responsecode field.

as far know, restkit cannot outward, since representation parameter gives info inside current context. however, on road map , there ticket already: https://github.com/restkit/restkit/issues/1327


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -