如何将URLRequest转换为Alamofire URLConvertible我尝试转换以下代码时遇到错误
var request = URLRequest(url: URL(string: "some url")!)
request.httpBody = json
RxAlamofire.request(.post, request as! URLConvertible, parameters: param, encoding: JSONEncoding.default, headers: ["Content-Type" : "application/json"])
.subscribe(onNext:{ [weak self] (json) in
print(json)
if let jsonResult = JSON(json) as? JSON {
if let cartResult = FoodCartResult(jsonResult) as? FoodCartResult {
self?.delegate?.showCart(cartresult: cartResult)
}
}
}, onError: {
[weak self] (error) in
print(error.localizedDescription)
self?.delegate?.onError()
},onCompleted: {})
.disposed(by: disposeBag)
代码使我的应用程序崩溃
无法将类型“ Foundation.URLRequest”(0x10c23a3c8)的值强制转换为“ Alamofire.URLConvertible”
已经推荐以下人,但不为我工作 Could not cast value of type 'NSMutableURLRequest' (0x11beb7040) to 'Alamofire.URLRequestConvertible' (0x11beb9040)