Does NSURLConnection choose its delegate automatically?
Does NSURLConnection automatically send messag开发者_开发知识库es to the class that initialized it or how does it work because I did not reference it in my header file.
No, you need to specify the delegate, as in this example from the URL Loading System Guide
// Create the request.
NSURLRequest *theRequest=[NSURLRequest
requestWithURL:[NSURL URLWithString:@"http://www.apple.com/"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
// create the connection with the request
// and start loading the data
NSURLConnection *theConnection=[[NSURLConnection alloc]
initWithRequest:theRequest delegate:self];
(note the delegate:self
part).
精彩评论