ios - How add different response mapping for same pathPattern in restkit-0.2? -


it possible, add couple of response mapping same pathpattern?

i have next situation:

      request:     rkentitymapping * restdaymapping = [restday entitymapping];     rkresponsedescriptor * restdaydescriptor = [rkresponsedescriptor responsedescriptorwithmapping:restdaymapping pathpattern:@"program/restdays" keypath:@"rest_days" statuscodes:statuscodes];           [manager addresponsedescriptor:restdaydescriptor];      put request:     rkobjectmapping * restdayputmapping = [rkobjectmapping requestmapping];     [restdayputmapping addattributemappingsfromdictionary:@{@"daynumber" : @"restdays.daynumber"}];      rkrequestdescriptor * restdayputdescriptor = [rkrequestdescriptor requestdescriptorwithmapping:[restdayputmapping inversemapping] objectclass:[userprogram class] rootkeypath:@"rest_days"];     [manager addrequestdescriptor:restdayputdescriptor];   

so both mappings send same path pattern: @"program/restdays" first request server side return json:

      {"rest_days":[{"daynumber":1},{"daynumber":4},{"daynumber":2}]}.  

for second put request, json:

      {"success" : "true"}  

how must configurate restkit mappings? thank you.

edit: upgrade restkit library , found wonderful feature, method depricated:

 + (instancetype)responsedescriptorwithmapping:(rkmapping *)mapping                                   pathpattern:(nsstring *)pathpattern                                       keypath:(nsstring *)keypath                                   statuscodes:(nsindexset *)statuscodes 

and added new one:

 + (instancetype)responsedescriptorwithmapping:(rkmapping *)mapping                                        method:(rkrequestmethod)method                                   pathpattern:(nsstring *)pathpattern                                       keypath:(nsstring *)keypath                                   statuscodes:(nsindexset *)statuscodes 

so can set different mappings different request methods. help.

you can have 2 different mappings same path pattern long used different purposes (like , put). restkit needs able tell 1 use, long can everything's fine.

there 2 ways put though:

objectmanager putobject:... 

this automatically try map response onto source object. if expect status response isn't going work well. alternatively can use restkit serialisation you:

nserror* error; nsdictionary *parameters = [rkobjectparameterization parameterswithobject:object requestdescriptor:requestdescriptor error:&error]; nsdata *json = [rkmimetypeserialization datafromobject:parameters mimetype:rkmimetypejson error:&error]; 

and put results (using restkit classes or nsurlconenction).

your best option may use rkobjectrequestoperation, technically won't using mappings against same path pattern can use mappings both create request , process response.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -