I am developing one small app in which i have multiple NSURLConnection.I have created that NSURL Connection but i don\'t know how to handle it.My code is like below.
you might want to take a look at AFNetworking for an easier and tidier way of doing network requests.
Implement NSURLConnection delegate methods and rest will be handle by itself
Declare conn,conn1,conn2,conn3 in .h file. Then do the following. in loadTrafficAndEvent:
conn1 = [[NSURLConnection alloc] initWithRequest:request1 delegate:self];
in connectionDidFinishDownloading: method,
- (void)connectionDidFinishDownloading:(NSURLConnection *)connection destinationURL:(NSURL *)destinationURL{
if(connection==conn){
conn1 = [[NSURLConnection alloc] initWithRequest:request1 delegate:self];
}
else if(connection==conn1){
conn2 = [[NSURLConnection alloc] initWithRequest:request2 delegate:self];
}
else if(connection==conn2){
conn3 = [[NSURLConnection alloc] initWithRequest:request3 delegate:self];
}
}
Do the operations inside each if else condition, and no need to allocate and initialize all NSURLConnection in loadTrafficAndEvent: The download will occur one after other.