ios - Manage AFNetworking multiple requests with AFHTTPClient enqueueBatchOfHTTPRequestOperationsWithRequests method -
i want create table view slide menu fb or linkedin, mean dynamically, have make requests @ same time. using afnetworking. custom afhtttpclient
called yplhttpclients , afhttpclient subclass. in class have 2 methods. sharedclient
, initwithbaseurl
.
i want use enqueuebatchofhttprequestoperationswithrequests
method in class return data viewcontroller , create tableview of menu.
i call method uses enqueuebatchofhttprequestoperationswithrequests
this function in client , return dictionary or information data, instead of in viewcontroller here:
nsmutablearray *mutablerequests = [nsmutablearray array]; (nsstring *urlstring in [nsarray arraywithobjects:@"users", @"intprojects", nil]) { [mutablerequests addobject:[[yplhttpclient sharedhttpclient] requestwithmethod:@"get" path:urlstring parameters:nil]]; } __block nsdictionary *parsedobject1, *parsedobject2; [[yplhttpclient sharedhttpclient] enqueuebatchofhttprequestoperationswithrequests:mutablerequests progressblock:^(nsuinteger numberofcompletedoperations, nsuinteger totalnumberofoperations) { nslog(@"%lu of %lu completed", (unsigned long)numberofcompletedoperations, (unsigned long)totalnumberofoperations); } completionblock:^(nsarray *operations) { nserror *thiserror; parsedobject1 = [nsjsonserialization jsonobjectwithdata:[[operations objectatindex:0] responsedata] options:nsjsonreadingmutablecontainers|nsjsonreadingallowfragments error:&thiserror]; nslog(@"completion: %@", parsedobject1 ); parsedobject2 = [nsjsonserialization jsonobjectwithdata:[[operations objectatindex:1] responsedata] options:nsjsonreadingmutablecontainers|nsjsonreadingallowfragments error:&thiserror]; nslog(@"completion: %@", parsedobject2 );
i know, how can show , image while downloading data.
thank you
i'm not entirely sure you're asking, can use mbprogresshud show progress bar that's updated in progressblock
(progress = numberofcompletedoperations / totalnumberofoperations).
Comments
Post a Comment