How to get Status Code from UIWebView for iPhone Development

Source: Internet
Author: User

IPhoneDevelopment fromUIWebView.Status CodeThe example tutorial is the content to be introduced in this article. This article is based on code implementation, and there is not much content. Let's look at the implementation code.

Obtain from UIWebViewStatus CodeFor example, if an error message such as 404 is returned, you can use the Code provided on the official website of apple.

 
 
  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.     }  

Summary:IPhoneDevelopment fromUIWebView.Status CodeI hope this article will help you with the introduction of the Instance tutorial.

From: http://www.cocoachina.com/iphonedev/sdk/2010/1202/2429.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.