Iphone NSURLConnection在接收不太大的od数据时挂起

Iphone NSURLConnection在接收不太大的od数据时挂起,iphone,objective-c,connection,nsurlconnection,ios4,Iphone,Objective C,Connection,Nsurlconnection,Ios4,我这里有一些代码: (...) NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if( theConnection ) { webData = [[NSMutableData data] retain]; } 和委托方法: -(void)connection:(NSURLConnection *)co

我这里有一些代码:

(...)
NSURLConnection *theConnection = [[NSURLConnection alloc] 
                initWithRequest:theRequest delegate:self];
if( theConnection )
{
    webData = [[NSMutableData data] retain];
}
和委托方法:

-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{   
    NSLog(@"zero");
   [webData setLength: 0];
}

-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    NSLog(@"got %d", [data length]);
    [webData appendData:data];
}

-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    NSLog(@"ERROR with theConenction");
    [connection release];
    [webData release];
}

-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{

    NSLog(@"DONE. Received Bytes: %d", [webData length]);
    [connection release];
    [webData release];      
}
它工作得很好,直到有更多的数据出现。 NSURLConnection停止工作,无错误、无异常、无退出。我仍然可以使用我的应用程序。 我注意到,当didReceiveData在连接过程中被多次调用时,问题就开始了

从调试器一步一步地看:

1. I call theRequest
2. Delegate call didReceiveResponse
2010-06-21 18:10:16.708 MyApp[9477:207]零

3. Delegate call didReceiveData
2010-06-21 18:10:16.709 MyApp[9477:207]获得6912

gdb继续

4. Delegate call didReceiveData (once again)
--> and here is the problem <--
2010-06-21 18:10:18.027 MyApp[9477:207]获得114067

gdb继续

4. Delegate call didReceiveData (once again)
--> and here is the problem <--
2010-06-21 18:15:18.041我的应用程序[9477:207]组合出现错误 连接失败!错误-操作无法完成。对等方重置连接

gdb继续

4. Delegate call didReceiveData (once again)
--> and here is the problem <--
===================更新====================

最后,我发现了一件重要的事情:真正的问题是,远程主机有时无法以正确的方式完成连接,例如,数据量大,因此无法调用委托ConnectiondFinishLoading,5分钟后,远程主机会重置连接


有人也有这个问题,可以帮忙吗

如果设置断点,是否说明它已停止在何处?

最后,我已使用

解决了此问题,但在一些循环后,它会冻结,对断点没有反应,XCode通知栏显示正在运行。。。但重要的是,程序的主线程不可用-我可以使用我的应用程序。您是否尝试过从另一台服务器加载一大块数据?这与特定服务器相关吗?使用POST请求时,iPhone SDK的默认计时器相当长。无论你进入什么地方,它都会停留很长时间。最后我自己制作了计时器。