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{}
不希望为此目的保留任何额外的类变量.
解决方法 这很简单 :-(voID)connectionDIDFinishLoading:(NSURLConnection *)connection{ if (connection == connection1) { //It's for connection1. } else if (connection == connection2) { //It's for connection2. }}
你可以通过这个美丽的SO问题:Managing multiple asynchronous NSURLConnection connections
总结以上是内存溢出为你收集整理的cocoa – 在委托中区分NSURLConnection对象全部内容,希望文章能够帮你解决cocoa – 在委托中区分NSURLConnection对象所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)