将NSMutableURLRequest的超时设置为自定义时间

Abh*_*nav 5 iphone cocoa-touch objective-c nsmutableurlrequest ios

可能重复:
如果数据开始加载但不是webViewDidFinishLoad,则不会触发NSMutableURLRequest超时

我正在使用Async HTTP请求并将我的NSMutableURLRequest的超时设置为30秒,我想在此时间内超时请求.

问题:请求没有超时30秒.超时始终需要90秒.任何解决方案.

这是我的连接代码:

NSMutableURLRequest *myRequest = [[NSMutableURLRequest alloc] initWithURL:myURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30];
[myRequest setHTTPMethod:@"POST"];
[myRequest setHTTPBody:myData];

NSURLConnection *myConnection = [[NSURLConnection alloc] initWithRequest:myRequest delegate:self];
Run Code Online (Sandbox Code Playgroud)

我正在实施以下门格:

- (void)connection:(NSURLConnection *)iConnection didReceiveResponse:(NSURLResponse *)iResponse;
- (void)connection:(NSURLConnection *)iConnection didReceiveData:(NSData *)iElementContructionContextData;
- (void)connection:(NSURLConnection *)iConnection didFailWithError:(NSError *)iError;
Run Code Online (Sandbox Code Playgroud)

Gyp*_*psa 5

您可以像这样设置timeOutSeconds的时间: -

[myRequest setTimeOutSeconds:1000];
Run Code Online (Sandbox Code Playgroud)

根据自己设置timeOutSecond.