URLSessionDelegate
SDKs
Framework
Foundation
NSURLSessionDelegate
协议描述URLSession对象在其delegates
上调用以处理会话级别事件的方法。
概述
除了此协议中定义的方法之外,大多数delegates
还应实现URLSessionTaskDelegate,URLSessionDataDelegate和URLSessionDownloadDelegate协议中的部分或全部方法来处理任务级别的事件。
注意
一个
NSURLSession
对象不需要delegate
。如果未分配delegate
,则使用系统提供的delegate
,并且你必须提供完成回调以获取数据。
主题
一、代理方法
● func urlSession(URLSession, didBecomeInvalidWithError: Error?)
通知URL会话该会话已失效。
● func urlSession(URLSession, didReceive: URLAuthenticationChallenge, completionHandler: (URLSession.AuthChallengeDisposition, URLCredential?) -> Void)
响应来自远程服务器的会话级别认证请求,从delegate
请求证书。
● func urlSessionDidFinishEvents(forBackgroundURLSession: URLSession)
告诉delegate
,会话中所有的消息都已发送。
二、常量
● enum URLSession.AuthChallengeDisposition
响应于认证质询,由会话或任务delegates
传递的常量代表所提供的继续闭包。
Constants passed by session or task delegates to the provided continuation block in response to an authentication challenge.