iPhone开发 从UIWebView中获取Status Code实例教程

移动开发 iOS
本文介绍的是从UIWebView中获取Status Code 实例教程,基于代码实现,我们一起来看内容。

iPhone开发 从UIWebView中获取Status Code 实例教程是本文要介绍的内容,本文是基于代码实现,内容不多,我们来看实现代码。

从 UIWebView 中获取 Status Code ,比如 404 之类的报错信息,可以使用苹果官网提供的代码

  1. - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {  
  2.     // check for HTTP status code for proxy authentication failures  
  3.     // anything in the 200 to 299 range is considered successful,  
  4.     // also make sure the MIMEType is correct:  
  5.     //  
  6.     NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;  
  7.     if ((([httpResponse statusCode]/100) == 2)) {  
  8.         // self.earthquakeData = [NSMutableData data];  
  9.         [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;  
  10.     } else {  
  11.         NSDictionary *userInfo = [NSDictionary dictionaryWithObject:  
  12.                                   NSLocalizedString(@"HTTP Error",  
  13.                                                     @"Error message displayed when receving a connection error.")  
  14.                                                              forKey:NSLocalizedDescriptionKey];  
  15.         NSError *error = [NSError errorWithDomain:@"HTTP" code:[httpResponse statusCode] userInfo:userInfo];  
  16.         [self handleError:error];  
  17.     }  

小结:iPhone开发 从UIWebView中获取Status Code 实例教程的内容介绍完了,希望本文对你有所帮助。

本文来自:http://www.cocoachina.com/iphonedev/sdk/2010/1202/2429.html

责任编辑:zhaolei 来源: 互联网
相关推荐

2014-08-26 11:46:46

QtAndroid实例教程

2011-08-17 10:09:25

iPhone开发UIWebViewTouch事件

2009-09-18 11:44:05

Scala实例教程Kestrel

2013-01-04 16:17:33

Android开发图像特效图像处理

2011-07-27 17:41:35

Objective-C Xcode

2019-06-17 15:25:17

expandunexpandLinux

2010-08-17 11:02:45

DIV CSS实例教程

2011-07-25 16:03:47

XCode 编译

2009-09-08 14:18:35

NFS服务器

2013-01-14 17:05:55

UCUI设计菜单栏

2010-08-25 17:08:18

实例教程

2009-07-30 14:18:02

ASP.NET实例教程

2011-08-22 15:15:49

iPhone开发NSMutableAr排序

2011-07-25 18:02:51

iPhone LibFetion 移植

2011-08-08 18:26:52

UIWebView图片

2011-08-08 16:56:44

iPhone 字符处理 视图

2011-08-10 15:48:10

iPhone网络

2013-08-15 09:14:55

2013-07-25 14:44:48

sqlite实例教程iOS开发学习sqlite打造词典

2010-06-18 15:55:47

UML建模
点赞
收藏

51CTO技术栈公众号