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.
- - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
- // check for HTTP status code for proxy authentication failures
- // anything in the 200 to 299 range is considered successful,
- // also make sure the MIMEType is correct:
- //
- NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
- if ((([httpResponse statusCode]/100) == 2)) {
- // self.earthquakeData = [NSMutableData data];
- [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
- } else {
- NSDictionary *userInfo = [NSDictionary dictionaryWithObject:
- NSLocalizedString(@"HTTP Error",
- @"Error message displayed when receving a connection error.")
- forKey:NSLocalizedDescriptionKey];
- NSError *error = [NSError errorWithDomain:@"HTTP" code:[httpResponse statusCode] userInfo:userInfo];
- [self handleError:error];
- }
- }
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