【发布时间】:2020-04-23 08:22:44
【问题描述】:
我正在制作一个自定义类,它在其初始化程序中采用 Alamofire DataRequest。现在我想给它添加一个 timeoutInterval,但是我得到了编译错误
“DataRequest”类型的值没有成员“timeoutInterval”
代码如下:
init(request: DataRequest, timeoutInterval: Double = 10) {
request.timeoutInterval = timeoutInterval // <- compile error here
self.request = request
}
显然 Alamofire DataRequest 没有该属性。但是有没有其他方法可以以这种方式指定请求的超时时间(最好不使用 SessionManager)? URLRequest 有,所以应该可以,但我不知道怎么做。
我知道之前在 Stack Overflow 上已经提出过这个问题,但我找不到任何适合这种情况的答案。
【问题讨论】:
-
当前使用 Alamofire 4.0
标签: swift alamofire nsurlrequest