• ASI-ASIHTTPRequest网络请求最近体验分享


    最近一直在看ASI请求数据这一块,都快蒙了都,其实我一直都是在懵懂的。

    上个月,刚进公司,同事扔给了我一份代码,打开我懵掉了,完全看不懂,因为从来没用过ASI请求,

    之前都是用的AFN,封装好的工具类,用起来很简单。

    公司的代码一切都很好,就是请求这点儿,搞的不尽人意,可能同事也没弄过,好多请求的地方都没顾及到,

    交给我的BUG,完全都是再请求结束,或者请求开始时的判断。

    我问了好多朋友,同学,都说不曾用过,只是让我百度,goole  可是,没辙吖,找不到。

    于是,自己摸索一天,找到了解决方案,

    其实他的请求方法很简单:

    - (void)setStartedBlock:(ASIBasicBlock)aStartedBlock

    {

    [startedBlockrelease];

    startedBlock = [aStartedBlock copy];

    }

    - (void)setHeadersReceivedBlock:(ASIHeadersBlock)aReceivedBlock

    {

    [headersReceivedBlockrelease];

    headersReceivedBlock = [aReceivedBlock copy];

    }

    - (void)setCompletionBlock:(ASIBasicBlock)aCompletionBlock

    {

    [completionBlockrelease];

    completionBlock = [aCompletionBlock copy];

    }

    - (void)setFailedBlock:(ASIBasicBlock)aFailedBlock

    {

    [failureBlockrelease];

    failureBlock = [aFailedBlock copy];

    }

    - (void)setBytesReceivedBlock:(ASIProgressBlock)aBytesReceivedBlock

    {

    [bytesReceivedBlockrelease];

    bytesReceivedBlock = [aBytesReceivedBlock copy];

    }

    - (void)setBytesSentBlock:(ASIProgressBlock)aBytesSentBlock

    {

    [bytesSentBlockrelease];

    bytesSentBlock = [aBytesSentBlock copy];

    }

    - (void)setDownloadSizeIncrementedBlock:(ASISizeBlock)aDownloadSizeIncrementedBlock{

    [downloadSizeIncrementedBlockrelease];

    downloadSizeIncrementedBlock = [aDownloadSizeIncrementedBlock copy];

    }

    - (void)setUploadSizeIncrementedBlock:(ASISizeBlock)anUploadSizeIncrementedBlock

    {

    [uploadSizeIncrementedBlockrelease];

    uploadSizeIncrementedBlock = [anUploadSizeIncrementedBlock copy];

    }

    - (void)setDataReceivedBlock:(ASIDataBlock)aReceivedBlock

    {

    [dataReceivedBlockrelease];

    dataReceivedBlock = [aReceivedBlock copy];

    }

    - (void)setAuthenticationNeededBlock:(ASIBasicBlock)anAuthenticationBlock

    {

    [authenticationNeededBlockrelease];

    authenticationNeededBlock = [anAuthenticationBlock copy];

    }

    - (void)setProxyAuthenticationNeededBlock:(ASIBasicBlock)aProxyAuthenticationBlock

    {

    [proxyAuthenticationNeededBlockrelease];

    proxyAuthenticationNeededBlock = [aProxyAuthenticationBlock copy];

    }

    - (void)setRequestRedirectedBlock:(ASIBasicBlock)aRedirectBlock

    {

    [requestRedirectedBlockrelease];

    requestRedirectedBlock = [aRedirectBlock copy];

    }

    主要的就这些,我们常用的,就是:

    //开始请求

    - (void)setStartedBlock:(ASIBasicBlock)aStartedBlock

    {

    [startedBlockrelease];

    startedBlock = [aStartedBlock copy];

    }

    //请求完成

    - (void)setCompletionBlock:(ASIBasicBlock)aCompletionBlock

    {

    [completionBlockrelease];

    completionBlock = [aCompletionBlock copy];

    }

     //请求失败

    - (void)setFailedBlock:(ASIBasicBlock)aFailedBlock

    {

    [failureBlockrelease];

    failureBlock = [aFailedBlock copy];

    }

    所以,希望可以帮到大家都ASI的了解。

  • 相关阅读:
    如何更改Web Service部署生成的App_Code.dll的名称
    Orcas中C#语言的新特性:自动属性,对象初始化器,和集合初始化器
    驗證類javascript
    多线程下WinForm开发应该注意哪些问题?
    把表从Access2007导出到Sql Server
    面向对象模型的四种核心技术
    ASP常用代碼二
    熊猫烧香代码
    简繁体互转代码
    上班人员必读:“五险一金”详解!
  • 原文地址:https://www.cnblogs.com/WLL-Hero/p/3765609.html
Copyright © 2020-2023  润新知