我正在创建我的 NSURLConnection ,如下所示:
theConnection = [[NSURLConnection alloc] initWithRequest:serviceRequest delegate:self];
我查看了 NSURLConnection 文档,显然取消 API 适用于异步请求,那么这在场景中是否有效?
无论如何,在我的其他课程中,当 NSURLConnection 正在进行时,我尝试这样做:
[mgr.theConnection cancel];
[mgr.theConnection release];
但是,代表仍然被调用,这是我不想要的。那么我如何正确地确保我取消连接,以便它的委托调用也被取消呢?
安慰:
2012-08-17 23:01:11.820 app[14097:707] Will cancel connection=(null)
2012-08-17 23:01:11.821 app[14097:707] Did cancel connection
2012-08-17 23:01:11.821 app[14097:707] Did release connection
2012-08-17 23:01:20.330 app[14097:707] didReceiveResponse
2012-08-17 23:01:20.331 app[14097:707] didReceiveData
2012-08-17 23:01:20.332 app[14097:707] connectionDidFinishLoading