ios - How to send array of dictionaries with big data using afnetworking 2.0 -
i have big array of dictionaries data of trips. want send in 1 request want responses after each dictionary send. using afnetworking 2.0 , use afhttprequestserializer serializer.
update. use method now, if user lot of data there risk can interrupted in case of bad internet. , have know trips been sent
- (void)sendtripdata:(nsarray*)trips withsuccessblock:(requestsuccessblockwithdict)successblock failureblock:(failureblock)failureblock { nsstring* path = @"add_trips"; nsdictionary *params = @{@"trips":trips, @"mobile_id":[[uidevice currentdevice].identifierforvendor uuidstring]}; [self post:path parameters:params success:^(afhttprequestoperation *operation, id responseobject) { nsloglight(@"full data trips send success"); if ([responseobject iskindofclass:[nsdictionary class]]) { nsdictionary* dict = (nsdictionary*) responseobject; if ([dict[@"status"] isequaltostring:@"ok"]) { successblock(responseobject); } else { failureblock(nil); } } else { failureblock(nil); } } failure:^(afhttprequestoperation *operation, nserror *error) { nsloglight(@"full data trips send failed"); nsstring* errorreason = nil; if (operation.response) { errorreason = error.localizedrecoverysuggestion; } failureblock(errorreason); }];
}
you should http pipelining. isn't afnetworking going with. 'standard' model http requests 1 request in, 1 response out. optimizations keep-alive , pipelining exist, take more work take advantage of.
Comments
Post a Comment