I have an issue that I really don't understand in Alamofire, probably Swift knowledge missing here.
I don't have any failure in my application, everything runs. It just ignore some closure at some point. Instead of finding my data inside my closure in debugger Xcode show me this :
0x0000000106eb1b30 AGKitCore partial apply forwarder for closure #1
(Alamofire.DataResponse<Swift.String>) -> () in static
AGKitCore.AGKit.add(document: Foundation.Data, withFileType:
AGKitCore.AGKit.documentType, withIdentifier:
Swift.Optional<Swift.String>, completionHandler: (Swift.Optional<Swift.Int>) -> ()) -> ()
To add more context AGKit is called statically like this :
AGKit.add(document: someData, withFileType: .jpeg, withIdentifier: self.cart_local_id) { statusCode in ...closure } ```
and the function :
AGKit.sharedInstance.core.api.upload(multipartFormData: { form in
form.append(document, withName: "image", fileName: identifierForDocument, mimeType: "")
}, with: Router.sendDocument(identifier: identifierForDocument)) { (results) in
switch results {
case .success(request: let uploadDocumentRequest, streamingFromDisk: _, streamFileURL: _):
//Pass here
uploadDocumentRequest.responseString(completionHandler: { responseString in
completionHandler(responseString.response!.statusCode) //this is never called
})
break
case .failure(let error): //No failure too
print(error.localizedDescription)
completionHandler(-1)
break
}
}
So how should I manage this use case of closure ? Thanks :D
(N.B : this is working very very well in Alamofire 4.3 and before, it has stopped working from 4.3+)
Update : So the error I was getting came from Alamofire that has a bug in a certain version : when a remote host wasn't responding at all (e.g when Alamofire could not resolve the host) the closure wasn't applied correctly. Instead nothing happen, which lead to this particular problem.