开发者

NSURLRequest timeOut handling

开发者 https://www.devze.com 2023-02-19 19:46 出处:网络
I\'ve been reading some issues here with NSURLRequest timeOut, but I see no answer to my problem. Well, here it is: my NSURLRequest object works fine, but I need to show some alert to the user if the

I've been reading some issues here with NSURLRequest timeOut, but I see no answer to my problem. Well, here it is: my NSURLRequest object works fine, but I need to show some alert to the user if the connection time out is higher to 3. And i dun know how to handle that timeout. Any help is really appreciate it.

NSURLRequest *requestOb开发者_开发百科j = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:3] ;
[webView setDelegate:self];
[webView loadRequest:requestObj];


Define a delegate for the web view -- add <UIWebViewDelegate> in the @interface definition of your view controller and then link it up in Interface builder

then add a method

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{

// whatever you want to do if it times out (or some other error)

}
0

精彩评论

暂无评论...
验证码 换一张
取 消