Alamofire 3とObjectMapper(https://github.com/Hearst-DD/ObjectMapper)の最新バージョンでAlamofireObjectMapper
(https://github.com/tristanhimmelman/AlamofireObjectMapper)を実装しようとしています。タイプ 'T?'の値を変換できません。期待される引数型 '_?' - 汎用タイプと完了ブロック
AlamofireObjectMapper
はAlamofire 3で動作するように更新されていないようですので、私はそれを自分でやろうとしています。
私はこのコードに来て、今私は立ち往生しています。
Generic Type Tは、応答の完了ブロック内にはアクセスできないと思われます。 Alamofire
3変更またはSwift 2.1変更ですか?
これはエラーです:
Cannot convert value of type 'T?' to expected argument type '_?'
public func responseObject<T: Mappable>(queue: dispatch_queue_t?, keyPath: String?, completionHandler: (NSURLRequest, NSHTTPURLResponse?, T?, AnyObject?, ErrorType?) -> Void) -> Self {
return response(queue: queue) { (request, response, data, error) -> Void in
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
let JSONResponseSerializer = Request.JSONResponseSerializer(options: .AllowFragments)
let result = JSONResponseSerializer.serializeResponse(request, response, data, error)
let parsedObject = Mapper<T>().map(keyPath != nil ? result.value?[keyPath!] : result.value)
dispatch_async(queue ?? dispatch_get_main_queue()) {
completionHandler(self.request!, self.response, parsedObject, result.value ?? response.data, result.error) // Here it shows the error: Cannot convert value of type 'T?' to expected argument type '_?'
}
}
}
}
ハハのためmabrilの答えに更新。幸いにも私はあなたの答えを早いうちに見ました。これは、有用なエラーメッセージを返すため、デバッグに数時間かかるバグです。ありがとうございました – villy393
"未解決の演算子 '**'"の使用:( –
うわー、このエラーは私のための次のパラメータにもありました(Xcode 8.0を実行中) – aryaxt