tags:

views:

17

answers:

1

Does NSURLConnection automatically send messages to the class that initialized it or how does it work because I did not reference it in my header file.

+1  A: 

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).

David Gelhar
One caveat: NSURLConnection retains its delegate. This caused me some fairly major headaches in the past...
robinjam
Thanks I will make a note of this!
TheLearner