2017-02-28 53 views
0

我有一個RestKit請求如下。我如何從響應頭獲取身份驗證令牌?Swift,我如何從RestKit獲得響應頭文件?

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



pod 'RestKit', '~> 0.27.0' 

回答

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 
} 
+0

我得到'RKObjectRequestOperation類型的值沒有成員響應# – markhorrocks

+0

@markhorrocks檢查編輯的答案。 –

+0

它喜歡'operation.httpRequestOperation' – markhorrocks