NSURLConnection协议在哪里?

ope*_*rog 4 iphone nsurlconnection

NSURLConnection的文档说有代理方法,如

connection:willSendRequest:redirectResponse: 
Run Code Online (Sandbox Code Playgroud)

但是文档没有提到要实现哪个委托协议.好吧,我假设代表没有任何协议,所以一切都只是可选的?

Ole*_*ann 13

它是在NSObject上作为类别实现的非正式协议NSURLConnection.h:

@interface NSObject (NSURLConnectionDelegate)
Run Code Online (Sandbox Code Playgroud)

这意味着NSObject的任何子类都可以是NSURLConnection的委托.是的,所有委托方法都是可选的.

  • 对于将来阅读此答案的任何人:[NSURLConnectionDelegate](http://developer.apple.com/library/mac/#documentation/Foundation/Reference/NSURLConnectionDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/ NSURLConnectionDelegate)是Mac OS X 10.7(Lion)的正式协议. (5认同)