[英]Why can't I make a request with SessionManager in Alamofire 4.0?
just upgraded to Alamofire 4.0 for Swift 3.0 support. 刚刚升级到Alamofire 4.0以获得Swift 3.0支持。 I was previously using a
Manager
object and making all requests from there. 我以前使用的是
Manager
对象并从那里发出所有请求。 This Manager
object has since been renamed to SessionManager
however there are no request
methods there anymore. 此
Manager
对象已重命名为SessionManager
但此处不再有request
方法。 Why is this? 为什么是这样? If I instead use
Alamofire.request
to make my requests then how do I use the session managers configuration with this? 如果我改为使用
Alamofire.request
来发出请求,那么如何使用会话管理器配置呢?
You should be able to use SessionManager.request. 您应该能够使用SessionManager.request。 From the docs :
来自文档 :
Top-level convenience methods like Alamofire.request use a default instance of Alamofire.SessionManager, which is configured with the default URLSessionConfiguration.
像Alamofire.request这样的顶级便捷方法使用Alamofire.SessionManager的默认实例,该实例使用默认的URLSessionConfiguration配置。
As such, the following two statements are equivalent:
因此,以下两个陈述是等效的:
Alamofire.request("https://httpbin.org/get") let sessionManager = Alamofire.SessionManager.default sessionManager.request("https://httpbin.org/get")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.