美文网首页
Alamofire源码解析 - Response

Alamofire源码解析 - Response

作者: wanglj | 来源:发表于2017-04-07 14:03 被阅读0次

定义了四种类型用于保存请求返回的数据

DefaultDataResponse

一般DataRequest对应的response

public struct DefaultDataResponse {
    /// The URL request sent to the server.
    public let request: URLRequest?

    /// The server's response to the URL request.
    public let response: HTTPURLResponse?

    /// The data returned by the server.
    public let data: Data?

    /// The error encountered while executing or validating the request.
    public let error: Error?

    /// The timeline of the complete lifecycle of the request.
    public let timeline: Timeline

    var _metrics: AnyObject?

    init(request: URLRequest?, response: HTTPURLResponse?, data: Data?, error: Error?, timeline: Timeline = Timeline()) {
        self.request = request
        self.response = response
        self.data = data
        self.error = error
        self.timeline = timeline
    }
}

DataResponse<Value>

和defauleDataRequest基本没有差别只是有一个泛型属性

DefaultDownloadResponse,DownloadResponse<Value>

和上面的dataresponse一样的作用

相关文章

网友评论

      本文标题:Alamofire源码解析 - Response

      本文链接:https://www.haomeiwen.com/subject/mfdhattx.html