开发者

Where's the NSURLConnection protocol?

The documentation of NSURLConnection says that there are delegate methods like

connection:willSendReq开发者_JS百科uest:redirectResponse: 

But the documentation doesn't mention which delegate protocol to implement. Well, I assume there just isn't any protocol for the delegate, so everything is just optional?


It's an informal protocol implemented in NSURLConnection.h as a category on NSObject:

@interface NSObject (NSURLConnectionDelegate)

That means any subclass of NSObject can be a delegate for NSURLConnection. Yes, all delegate methods are optional.


There is not one, and while there probably ought to be for completeness, it is unnecessary. Objective-C works on a concept called Duck typing which basically means if there is a method on an object, even if it is not part of a protocol or header definition a message can still be sent to it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜