IOS 网络连接相关资源

IOS参考官方文档:

https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html

如果你想下载URL所制定的内容,必须要要实现这个协议:NSURLConnectionDelegate 其中的几个方法:

In order to download the contents of a URL, an application needs to provide a  delegate   object that, at a minimum, implements the following delegate methods: 


connection:didReceiveResponse:

connection:didReceiveData:

connection:didFailWithError:

connectionDidFinishLoading:

1:如果执行了:connection:didFailWithError: 消息,那么从NSError可以提取: [error code] 和 [error userInfo](返回一个字典)

我们可以从字典中抽取出:NSURLErrorFailingURLStringErrorKey 所对应的消息:

NSString object for the URL which caused a load to fail

如果执行这个消息的话,其他的代理方法将不会再执行!

it receives no further delegate messages for the specified connection.

相关概念:

服务器端验证:

NSURLCredentialStorage

continueWithoutCredentialForAuthenticationChallenge(消息)

  sendSynchronousRequest:returningResponse:error:(发送同步请求)

疑问:

1:同步发送请求和异步发送请求在IOS中有什么差别呢?

2:如何创建认证证书或者认证凭证呢?

猜你喜欢

转载自xiaoxuejie.iteye.com/blog/1671756