NSURLProtocol官方文档的理解
官方提供的实例与方法如下:
- (instancetype)initWithRequest:(NSURLRequest *)request cachedResponse:(nullable NSCachedURLResponse *)cachedResponse client:(nullable id <NSURLProtocolClient>)client NS_DESIGNATED_INITIALIZER;
@property (nullable, readonly, retain) id <NSURLProtocolClient> client;
@property (readonly, copy) NSURLRequest *request;
@property (nullable, readonly, copy) NSCachedURLResponse *cachedResponse;
/*======================================================================
Begin responsibilities for protocol implementors
The methods between this set of begin-end markers must be
implemented in order to create a working protocol.
======================================================================*/
+ (BOOL)canInitWithRequest:(NSURLRequest *)request;
+ (NSURLRequest *)canonicalRequestForRequest:(NSURLRequest *)request;
+ (BOOL)requestIsCacheEquivalent:(NSURLRequest *)a toRequest:(NSURLRequest *)b;
- (void)startLoading;
- (void)stopLoading;
/*======================================================================
End responsibilities for protocol implementors
======================================================================*/
+ (nullable id)propertyForKey:(NSString *)key inRequest:(NSURLRequest *)request;
+ (void)setProperty:(id)value forKey:(NSString *)key inRequest:(NSMutableURLRequest *)request;
+ (void)removePropertyForKey:(NSString *)key inRequest:(NSMutableURLRequest *)request;
+ (BOOL)registerClass:(Class)protocolClass;
+ (void)unregisterClass:(Class)protocolClass;

本文解析了NSURLProtocol官方文档,介绍了协议实现者必须实现的方法,如开始加载请求、停止加载等,并展示了初始化方法及属性如客户端、请求和缓存响应。
1139

被折叠的 条评论
为什么被折叠?



