![](/img/trans.png)
[英]xcode 7 cannot assign a value of type '[NSHTTPCookie]' to a value of type '[NSHTTPCookie]'
[英]NSHTTPCookie cookiesWithResponseHeaderFields
調用API時,我收到以下響應:
<NSHTTPURLResponse: 0x7f96f0510f80> { URL: https://insula.magister.net/api/sessie } { status code: 201, headers {
"Cache-Control" = "max-age=120, private";
"Content-Length" = 0;
Date = "Thu, 30 Jul 2015 17:27:11 GMT";
"Set-Cookie" = "SESSION_ID=c8714acb-22f8-4295-90ee-82e9469890e1; domain=insula.magister.net; path=/api; secure; httponly";
"Strict-Transport-Security" = "max-age=31536000";
Vary = "Accept-Encoding,Cookie";
"X-Frame-Options" = DENY;
} }
print(HTTPResponse.allHeaderFiles)
打印以下輸出:
[Set-Cookie: SESSION_ID=65a59001-de75-41ff-ad22-70549baa96f5; domain=insula.magister.net; path=/api; secure; httponly, Strict-Transport-Security: max-age=31536000, Date: Thu, 30 Jul 2015 17:33:13 GMT, X-Frame-Options: DENY, Content-Length: 0, Cache-Control: max-age=120, private, Vary: Accept-Encoding,Cookie]
但是我無法使cookiesWithResponseHeaderFields
正常工作,我應該將[String:String]
數組作為第一個參數傳遞,但是響應似乎不符合要求。
let cookies = NSHTTPCookie.cookiesWithResponseHeaderFields(HTTPResponse.allHeaderFields, forURL: url)
但是由於HTTPResponse.allHeaderFiles
是[NSObject:AnyObject]
類型的數組,因此無法滿足[String:String]
參數類型。 誰知道該怎么辦?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.