cocoa - Differentiate between NSURLConnection objects in delegate -


i have 2 request starting 1 after other. starting request this

nsurl *url = [nsurl urlwithstring:[nsstring stringwithformat:@"http://www.google.com"]]; nsurlrequest *request = [nsurlrequest requestwithurl:url cachepolicy:nsurlrequestreloadignoringlocalcachedata timeoutinterval:60]; nsurlconnection * connection = [[nsurlconnection alloc]                                 initwithrequest:request                                 delegate:self startimmediately:no]; [connection scheduleinrunloop:[nsrunloop mainrunloop]                       formode:nsdefaultrunloopmode]; [connection start]; 

and request starting this.

nsurl *url1 = [nsurl urlwithstring:[nsstring stringwithformat:@"http://www.apple.com"]]; nsurlrequest *request1 = [nsurlrequest requestwithurl:url1 cachepolicy:nsurlrequestreloadignoringlocalcachedata timeoutinterval:60]; nsurlconnection *connection1 = [[nsurlconnection alloc] initwithrequest:request1 delegate:self]; [connection1 release]; 

how can differentiate between these 2 in delegate method?

-(void)connectiondidfinishloading:(nsurlconnection *)connection{} 

don't want keep class variable purpose.

it's simple :

-(void)connectiondidfinishloading:(nsurlconnection *)connection {      if (connection == connection1)      {          //it's connection1.      }      else if (connection == connection2)      {          //it's connection2.      } } 

you can go through beautiful question : managing multiple asynchronous nsurlconnection connections


Comments