I want to do two async request from two different kml file, so I setup two requests first:
NSString *server1URL = [NSString stringWithFormat:...];
NSMutableURLRe
How about assigning tags to each connection and checking the tags via an if/else or switch in the connectionDidFinishLoading?
- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
if( [connection isEqual: AConnection] ){
// do connection A stuff
}
else if( [connection isEqual: BConnection] ){
// do connection B stuff
}
}
Use GCD with sendSynchronousRequest: requests, they will be run in the background.
Example:
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(queue, ^{
NSURLRequest *request = [NSURLRequest requestWithURL:url1];
NSURLResponse *response;
NSError *error;
NSData *data1 = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
// do something with the data
});
dispatch_async(queue, ^{
NSURLRequest *request = [NSURLRequest requestWithURL:url2];
NSURLResponse *response;
NSError *error;
NSData *data2 = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
// do something with the data
});