Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ObjectiveV

macrumors newbie
Original poster
Nov 3, 2011
29
0
This may be a dumb question but I'm a bit confused about where i should and should not declare that I implement a protocol.

Ive been trying to just download the results of a http request to a NSString and most the tutorials i went to lead me to write this block

Code:
webdata = [NSMutableData new];
    NSString *urlString = [NSString stringWithFormat:@"http://www.google.com"];
    myConnection =[NSURLConnection connectionWithRequest:
                   [NSURLRequest requestWithURL:
                    [NSURL URLWithString:urlString]] 
                                                delegate:self];

Everything works fine, but why didn't the compiler yell at me for not stating that I am implementing the protocol NSURLConnection would need to to comply to to be its delegate?

If for nothing else, stating that I'm going to implement a protocol lets xcode help me a bit more in its auto completion.

So why does it let me do this? Should I still state that I implement the NSURLConnectionDelegate protocol just to be sure?

Thanks for any advice.
 
Everything works fine, but why didn't the compiler yell at me for not stating that I am implementing the protocol NSURLConnection would need to to comply to to be its delegate?
All the protocol methods are optional. That's probably why.

Should I still state that I implement the NSURLConnectionDelegate protocol just to be sure?
Sure, why not.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.