【问题标题】:iOS5 - Implementing NSURLConnection sendAsynchronousRequest:iOS5 - 实现 NSURLConnection sendAsynchronousRequest:
【发布时间】:2012-07-31 19:21:04
【问题描述】:

我熟悉使用以下方法。我知道在使用以下内容时,您至少需要实现所需的协议方法:

 [NSURLConnection setConnection:[[NSURLConnection alloc] initWithRequest:request delegate:self]];

有人能解释一下我在研究期间还没有得到答案的事情吗?

使用下面的异步方法调用时呢?是否有任何必需的协议方法需要从 NSURLConnection 实现?

谢谢

[NSURLConnection sendAsynchronousRequest:request
                                   queue:queue
                       completionHandler:^(NSURLResponse *response,NSData *data,NSError *error) 
                    { 

                        //Handle response here 
                    });

【问题讨论】:

    标签: objective-c ios5 nsurlconnection nsurlconnectiondelegate


    【解决方案1】:

    看文档,不需要实现任何协议。

    这将为您提供与使用 sendSynchronousRequest:returningResponse:error: 相同的结果,除了:

    1) 您的请求将是异步的

    2)您的处理程序将在您传递的队列中执行。

    【讨论】:

    • 不完全。您提供的队列是执行完成块的队列,而不是执行同步请求的队列。
    猜你喜欢
    • 1970-01-01
    • 2015-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多