Code like this:
import Foundation
import Alamofire
struct Request {
var alamoFireManager : SessionManager?
init() {
let configuration = URLSessionConfiguration.default
configuration.timeoutIntervalForRequest = 20
configuration.requestCachePolicy = .useProtocolCachePolicy
alamoFireManager = Alamofire.SessionManager(configuration: configuration)
}
func sendRequest() {
alamoFireManager?.request(url,method: method, parameters: body, encoding: JSONEncoding.default,headers: headers).responseJSON { response in
}
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…