1

I have a scenario where a NSURLConnection is in progress.

As we all know, CDMA phones (think Verizon, Sprint) can't handle data and phone calls at the same time. Does anyone know what, if any, NSError is returned when the connection is interrupted by a phone call?

Is there any error handling? Does didFailWithError get called or does it automatically go into the background?

Thank you in advance.

4

2 回答 2

2

这是一个很好的问题。虽然我不知道这个案例的具体答案,但如果你实现了这个 NSURLConnection 函数:

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error

并在使用 xcode 调试的设备上运行您的代码,您应该能够自己看到。

编辑:

添加到另一个答案中,我找到了所有 URL 错误的列表,因此希望您可以缩小要查找的范围。 错误

投稿前编辑:我找到了!错误是:NSURLErrorCallIsActive

当电话呼叫在不支持同时电话和数据通信(EDGE 或 GPRS)的网络上处于活动状态时尝试连接时返回。

于 2012-05-17T20:07:54.227 回答
1

//连接:didFailWithError:错误

-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
 //handle error here
    if([error code] == NSURLErrorCallIsActive)//error code for NSURLErrorCallIsActive = -1019
    {
        //if we can identify the error
    }else{
        //otherwise handle the error generally
    }
}
于 2012-05-17T21:09:33.647 回答