I am making 3 NSURLConnection requests on app start and exit in appdelegate.m, I am using asynchronous call, the response returned is array of dictionaries, with array having same name in all responses, so I cannot check with key.
So I tried declaring NSURLConnection variables in appdelgate.h and then in connectionDidFinishloading compared each declared connection object with connection paramter
//Appdelegate.h
NSURLConnection *conn1;
NSURLConnection *conn2;
NSURLConnection *conn3;
then in //Appdelgate.m
- (void)applicationDidBecomeActive:(UIApplication *)application
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://xyz/login"]];
request setValue:@"application/json;charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request setHTTPMethod:@"GET"];
conn1 = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
[conn1 start];
}
then
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
// The request is complete and data has been received
// You can parse the stuff in your instance variable now
NSError *e = nil;
NSDictionary *response = [NSJSONSerialization JSONObjectWithData: m_responseData options: 0 error: &e];
//Extracy spcific keys and add to respective arrays
if(connection == conn1)
{
//call 2 nd request
}
if(connection == conn2)
{
//call 3 rd request
}
}
I checked info of connection object, it always shows me this
<NSURLConnection: 0x14d09c20> { request: <NSMutableURLRequest: 0x14d0ac70> { URL: http://xyz/login } }
Even after calling second request it still shows me first request.
So comparison is failing..
So what can be better approach for this, or is it I am missing something.