NSURLProtocol

NSURLProtocol注册与初始化
本文介绍了NSURLProtocol对象如何处理特定协议的URL加载,并详细解释了注册协议类的过程及其作用。当URL加载系统开始加载请求时,已注册的协议类会依次被咨询是否能初始化请求。首个返回可以初始化的协议类将负责执行URL加载。

An NSURLProtocol object handles the loading of protocol-specific URL data.

 

@abstract This method registers a protocol class, making it visible

    to several other NSURLProtocol class methods.

    @discussion When the URL loading system begins to load a request,

    each protocol class that has been registered is consulted in turn to

    see if it can be initialized with a given request. The first

    protocol handler class to provide a YES answer to

    <tt>+canInitWithRequest:</tt> "wins" and that protocol

    implementation is used to perform the URL load. There is no

    guarantee that all registered protocol classes will be consulted.

    Hence, it should be noted that registering a class places it first

    on the list of classes that will be consulted in calls to

    <tt>+canInitWithRequest:</tt>, moving it in front of all classes

    that had been registered previously.

    <p>A similar design governs the process to create the canonical form

    of a request with the <tt>+canonicalRequestForRequest:</tt> class

    method.

    @param protocolClass the class to register.

    @result YES if the protocol was registered successfully, NO if not.

    The only way that failure can occur is if the given class is not a

    subclass of NSURLProtocol.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值