简体   繁体   English

部分应用转发器在Alamofire> 4.3调用期间关闭

[英]Partial Apply forwarder in closure during Alamofire > 4.3 call

I have an issue that I really don't understand in Alamofire, probably Swift knowledge missing here. 我有一个问题,我在Alamofire中真的不明白,可能在这里缺少Swift知识。

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 : 而不是在调试器Xcode中的闭包内找到我的数据给我看:

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会静态调用,如下所示:

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 感谢:D

(NB : this is working very very well in Alamofire 4.3 and before, it has stopped working from 4.3+) (注意:这在Alamofire 4.3中非常好用,之前已经停止了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 (eg when Alamofire could not resolve the host) the closure wasn't applied correctly. 更新:所以我得到的错误来自Alamofire,在某个版本中有一个错误:当一个远程主机完全没有响应时(例如当Alamofire无法解析主机时),关闭没有正确应用。 Instead nothing happen, which lead to this particular problem. 相反,没有任何事情发生,导致这个特殊问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM