iphone - RestKit send post request, parse the result? -
i'm trying pull data web service api , parse received json... i've been though restkit tutorials, couldn't find information on doing post request!
right have code:
-(void) loadperformers { // create our request mapping rkobjectmapping* requestmapping = [rkobjectmapping mappingforclass:[jsonoperationmodel class]]; [requestmapping addattributemappingsfromarray:@[@"requesttype"]]; // create our data mapping rkobjectmapping* datamapping = [rkobjectmapping mappingforclass:[datamodel class] ]; [datamapping addattributemappingsfromarray:@[@"status"]]; // create our performer mapping rkobjectmapping* performermapping = [rkobjectmapping mappingforclass:[performermodel class] ]; [performermapping addattributemappingsfromarray:@[@"idperformer", @"name", @"rate", @"isinwatch", @"rating", @"pictureurl", @"lastmodifieddate"]]; // create our talent mapping rkobjectmapping* talentmapping = [rkobjectmapping mappingforclass:[datamodel class] ]; [talentmapping addattributemappingsfromarray:@[@"id", @"value"]]; // define relationship mapping request -> data [requestmapping addpropertymapping:[rkrelationshipmapping relationshipmappingfromkeypath:@"data" tokeypath:@"data" withmapping:datamapping]]; // define relationship mapping data -> performers [requestmapping addpropertymapping:[rkrelationshipmapping relationshipmappingfromkeypath:@"performers" tokeypath:@"performers" withmapping:performermapping]]; // define relationship mapping performer -> talent [requestmapping addpropertymapping:[rkrelationshipmapping relationshipmappingfromkeypath:@"talents" tokeypath:@"talents" withmapping:talentmapping]]; rkresponsedescriptor *responsedescriptor = [rkresponsedescriptor responsedescriptorwithmapping:jsonoperationmapping pathpattern:nil keypath:nil statuscodes:rkstatuscodeindexsetforclass(rkstatuscodeclasssuccessful)]; nsurl *url = [nsurl urlwithstring:@"http://10.10.5.106:8089/mobile/default.ashx"]; nsurlrequest *request = [nsurlrequest requestwithurl:url]; rkobjectrequestoperation *objectrequestoperation = [[rkobjectrequestoperation alloc] initwithrequest:request responsedescriptors:@[ responsedescriptor]]; [objectrequestoperation setcompletionblockwithsuccess:^(rkobjectrequestoperation *operation, rkmappingresult *mappingresult) { rkloginfo(@"result: %@", mappingresult.array); } failure:^(rkobjectrequestoperation *operation, nserror *error) { rklogerror(@"operation failed error: %@", error); }]; [objectrequestoperation start]; }
which sample on official tutorial of restkit, modified needs according json. how can adapt sample send json string url, , fetch server anwser?
i couldn't find information on that, , each of server response needs client information sent through json string before being able send response client. (it's isn't fetching url current sample does!)
thanks input on this!
Comments
Post a Comment