【问题标题】:Swift, how can I get response headers from RestKit?Swift,如何从 RestKit 获取响应标头?
【发布时间】:2017-07-19 11:31:33
【问题描述】:

我有一个如下的 RestKit 请求。如何从响应标头中获取身份验证令牌?

    RKObjectManager.shared()
        .getObjectsAtPath(urlString,
                      parameters: paramsDictionary,
             success: {(operation: RKObjectRequestOperation?, result: RKMappingResult?) -> Void in



pod 'RestKit', '~> 0.27.0'

【问题讨论】:

    标签: swift3 restkit


    【解决方案1】:

    你可以像这样从RKObjectRequestOperation获取响应头。

    if let operation = operation, let headers = operation.httpRequestOperation.response.allHeaderFields as? [String:Any] {
        print(headers)// Now use subscript with headers dictionary to get your token value
    }
    

    【讨论】:

    • 我收到Value of type RKObjectRequestOperation has no member response
    • 点赞operation.httpRequestOperation
    • @markhorrocks 实际上我已经从我的目标 C 中添加了代码,已编辑答案:)
    猜你喜欢
    • 2017-07-28
    • 2015-11-15
    • 2013-05-28
    • 1970-01-01
    • 2014-03-10
    • 1970-01-01
    • 2015-03-11
    • 2017-03-27
    • 2016-12-21
    相关资源
    最近更新 更多