ios7 – 在iOS 7中设置Alamofire中的自定义HTTP标头不工作

ios7 – 在iOS 7中设置Alamofire中的自定义HTTP标头不工作,第1张

概述我试图在iOS 7中使用自定义HTTP标头设置Alamofire.Manager.sharedInstance.session.configuration.HTTPAdditionalHeaders,但我没有运气. 这可以在iOS 8中正常工作. 有没有人有什么建议? 我得到它的工作 这对iOS7没有影响: Alamofire.Manager.sharedInstance.session.conf 我试图在iOS 7中使用自定义http标头设置Alamofire.Manager.sharedInstance.session.configuration.httpAdditionalheaders,但我没有运气.

这可以在iOS 8中正常工作.

有没有人有什么建议?

解决方法 我得到它的工作

这对iOS7没有影响:

Alamofire.Manager.sharedInstance.session.configuration.httpAdditionalheaders = ["Customheader": customValue]

然而,这将适用于iOS7和8:

var headers = Alamofire.Manager.sharedInstance.session.configuration.httpAdditionalheaders ?? [:]    headers["Customheader"] = customValue    let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()    configuration.httpAdditionalheaders = headers    Alamofire        .Manager(configuration: configuration)        .request(.GET,"https://example.com/API/users",parameters: nil,enCoding: .JsON)
总结

以上是内存溢出为你收集整理的ios7 – 在iOS 7中设置Alamofire中的自定义HTTP标头不工作全部内容,希望文章能够帮你解决ios7 – 在iOS 7中设置Alamofire中的自定义HTTP标头不工作所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1097023.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存