gpt4 book ai didi

iphone - didReceiveResponse 是否保证在 connectionDidFinishLoading 之前?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:33:53 26 4
gpt4 key购买 nike

背景:在握手过程中,我的 iOS 应用学习服务器能力

  1. didReceiveResponse中查看其头信息

  2. connectionDidFinishLoading 中解析其响应 XML>

问题陈述:由于回调 #1 在 #2 之前,我将版本字符串存储在 didReceiveResponse 中,稍后在 connectionDidFinishLoading 中检查它响应可用。

幸运的是,到目前为止它运行良好,因为 #1 在 #2 之前。但是网络/iOS 总是保证该顺序吗?

最佳答案

来自 NSURLCOnnection Reference :

Zero or more connection:didReceiveResponse: messages will be sent

to the delegate before receiving a connection:didReceiveData: message. The only case where connection:didReceiveResponse: is not sent to a delegate is when the protocol implementation encounters an error before a response could be created.

Zero or more connection:didReceiveData: messages will be sent

before any of the following messages are sent to the delegate: connection:willCacheResponse:, connectionDidFinishLoading:, connection:didFailWithError:.

Zero or one connection:willCacheResponse: messages will be sent to

the delegate after connection:didReceiveData: is sent but before a connectionDidFinishLoading: message is sent.

因此,只有在创建响应之前出现错误时才会发生这种情况。

关于iphone - didReceiveResponse 是否保证在 connectionDidFinishLoading 之前?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7360526/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com