In my view controller’s viewDidLoad method, I create an NSURLConnection
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest
delegate:self]
You can see I set the delegate to self.
Then I implemented the delegate method
-(void) connection: (NSURLConnection*) connection didReceiveResponse: (NSURLResponse*) reponse {
//myImplementation;
}
This implementation is only defined in the @implementation ViewController @end block, and it is not declared in the ViewController‘s @interface.
So I guess this method is private? It compiles and runs well. But I just can’t call this method like [self connection: connection didReceiveResponse: response] in the ViewController‘s own methods.
What’s the explanation?
The methods are declared via your inclusion of the
NSURLConnectionDelegateprotocol in the class’s interface definition:This tells the compiler that your class promises to implement all the required methods of that protocol, and that it may implement the optional methods (as it happens, this particular protocol has only optional methods). So the declarations exist publicly, they’re just in another file.