I'm creating the extension for DataRequest to log events
func log() -> Self {
let responseSerializer = DataRequest.jsonResponseSerializer(options: .allowFragments)
return response(queue: nil, responseSerializer: responseSerializer) { response in
if let object = response.result.value {
/* do the job */
}
}
}
and got the error Unable to infer closure type in the current context
Since it has (DataResponse<T.SerializedObject>) -> Void
generic type, is there a way to explicitly set the type to fix this error?
Alamofire version: 4.7.2 Xcode version: 9.3 Swift version: 4.0 Platform(s) running Alamofire: iOS
func log() -> Self {
let responseSerializer = DataRequest.jsonResponseSerializer()
return response(responseSerializer: responseSerializer) { [weak self] response in
guard let _self = self else { return }
_self.printRequestString(response)
}
}
Works well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.