Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone ASIHTTPRequest超时不工作_Iphone_Objective C_Ipad_Asihttprequest - Fatal编程技术网

Iphone ASIHTTPRequest超时不工作

Iphone ASIHTTPRequest超时不工作,iphone,objective-c,ipad,asihttprequest,Iphone,Objective C,Ipad,Asihttprequest,代码如下所示,但是我不明白为什么即使10秒过去了它也没有超时。有什么想法吗 __block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:sourceURL]; [request setTimeOutSeconds:5.0]; [request setDelegate:self]; [r

代码如下所示,但是我不明白为什么即使10秒过去了它也没有超时。有什么想法吗

__block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:sourceURL];
                        [request setTimeOutSeconds:5.0];
                        [request setDelegate:self];
                        [request setCompletionBlock:^{
                            //some code
                        }];

                        [request setFailedBlock:^{
                            //some code

                        }];


                        self.currentRequest_ = request;
                        [self.currentRequest_ startAsynchronous];


    - (void)requestFailed:(ASIHTTPRequest *)request {
        NSLog(@"FAILED");
    }

我不认为你把
-[ASIHTTPRequest StartSynchronous]
。。。而是将请求(是
NSOperation
的子类)添加到
ASINetworkQueue
(是
NSOperationQueue
的子类)中。那么,请求是否成功完成了


另一种可能性是,至少每5秒接收一次数据,但尚未接收到完整数据。ASI只有在超时期间未收到任何信息时才会超时,因此,如果数据不断到达,则请求不会超时。

此外,
ASINetworkQueue
在暂停状态下启动,因此添加请求后,请务必调用
-[ASINetworkQueue go]
。您可能需要查找该方法的调用内容。。我忘了。啊哈……我想事情就是这样。。数据不断地被提取,只是速度很慢。。有没有一种方法可以停止忽略是否收到了数据?AsiTpRequest中没有内置任何内容。您可以自己设置一个NSTimer,这可能是最简单的方法。