I am trying to implement AlamofireObjectMapper ( https://github.com/tristanhimmelman/AlamofireObjectMapper ) using Alamofire 3 and the latest version of ObjectMapper ( https://github.com/Hearst-DD/ObjectMapper ).
It seems that AlamofireObjectMapper not been updated to work with Alamofire 3, so I'm trying to do it myself.
I came to this piece of code and now I'm stuck.
It seems that the generic type T is not available inside the response completion block. Is there a change in Alamofire 3 or a change in Swift 2.1?
This is mistake:
Cannot convert value of type 'T?' to the expected type of arguments '_?'
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)
source share