Where is the NSURLConnection protocol?

NSURLConnection documentation says that there are delegation methods like

connection:willSendRequest:redirectResponse: 

However, the documentation does not mention which delegate protocol to implement. Well, I suppose there is simply no protocol for the delegate, so is everything just optional?

+4
source share
2 answers

This is an unofficial protocol implemented in NSURLConnection.h as a category in NSObject:

 @interface NSObject (NSURLConnectionDelegate) 

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

+13
source

There is more than one, and although it should probably be for completeness, this is not necessary. Objective-C is working on the concept of duck typing , which basically means that there is a method on the object, even if it is not part of the protocol or the message header, it can still be sent to it.

0
source

All Articles