嗨,我对 Alamofire 的反应式扩展有问题
这是:
extension Alamofire.Manager{
func rac_jsonRequest<T : Decodable, G : ErrorType>(method: Alamofire.Method,_ URLString: URLStringConvertible, parameters: [String: AnyObject]? = nil, encoding: ParameterEncoding = .URL, headers: [String: String]? = nil) -> SignalProducer<T,G> {
SignalProducer<T,G> { sink, disposable in
let request = self.request(method, URLString, parameters: parameters, encoding: encoding, headers: headers).responseJSON { response in
if let JSON = response.result.value{
if let decoded : T = decode(JSON){ //ERROR THIS
sink.sendNext(decoded)
sink.sendCompleted()
}
}
}
disposable.addDisposable({request.cancel()})
}
}
}
我收到此错误:
没有“解码”候选产生预期的上下文结果类型“T?”