是否所有NSURLConnections异步连接? IOS [英] Does all NSURLConnections connect asynchronously? iOs

查看:88
本文介绍了是否所有NSURLConnections异步连接? IOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过一些例子NSURLConnection的看着,并且都评为异步相关的,虽然我没有看到创建的任何操作队列/线程/调度。
我wondeirng - 确实NSURLConnection的始终异步preform要求,或者您需要设置一些特别的东西吧。

I've looked through some NSURLConnection examples, and all are titled as related asynchronously, although I didn't see any operation queue / thread/ dispatch created. I was wondeirng - does NSURLConnection always preform requests asynchronously or you have to set something special for it?

推荐答案

NSURLConnection的可以根据你所说的方法来进行实际连接一旦你分配的NSURLConnection的实例(或使用类同步或异步模式下运行方法)。

NSURLConnection can be run in synchronous or asynchronous mode depending on what method you call to make the actual connection once you've allocated the NSURLConnection Instance (or use the Class Methods).

对于同步连接,您使用的方法:

For synchronous Connections, you use the method:

+(NSData的*)sendSynchronousRequest:(*的NSURLRequest)要求returningResponse:(NSURLResponse **)响应误差:(NSError **)误差

有关异步连接,您使用的方法:

For asynchronous connections, you use the methods:

+(NSURLConnection的*)connectionWithRequest:(*的NSURLRequest)申请委托:(ID< NSURLConnectionDelegate>)的委托

- (ID)initWithRequest:(*的NSURLRequest)申请委托:(ID< NSURLConnectionDelegate>)的委托

- (ID)initWithRequest:(的NSURLRequest *)申请委托:(ID< NSURLConnectionDelegate>)委托startImmediately:(BOOL)startImmediately

- (无效)启动

我建议你阅读苹果文档的<一个href=\"http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html\"相对=nofollow> NSURLConnection的,以了解更多信息和查看样品code

I recommend reading Apple's Documentation on NSURLConnection to find out more information and looking at sample code

这篇关于是否所有NSURLConnections异步连接? IOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆