简体   繁体   中英

Why can't I make a request with SessionManager in Alamofire 4.0?

just upgraded to Alamofire 4.0 for Swift 3.0 support. I was previously using a Manager object and making all requests from there. This Manager object has since been renamed to SessionManager however there are no request methods there anymore. Why is this? If I instead use Alamofire.request to make my requests then how do I use the session managers configuration with this?

You should be able to use 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.

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") 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM