我有两个请求,一个接一个地开始。像这样的起始请求区分委托中的NSURLConnection对象
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];
和另一个请求开始像这样。
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];
我如何区分这两个委托方法?
-(void)connectionDidFinishLoading:(NSURLConnection *)connection{}
不想为此保留任何额外的类变量。
检查回调方法中的'connection'参数是否等于代码中的'connection'或'connection1'变量。 – Markus 2013-05-06 07:17:08