iPhone開(kāi)發(fā) 從UIWebView中獲取Status Code實(shí)例教程
iPhone開(kāi)發(fā) 從UIWebView中獲取Status Code 實(shí)例教程是本文要介紹的內(nèi)容,本文是基于代碼實(shí)現(xiàn),內(nèi)容不多,我們來(lái)看實(shí)現(xiàn)代碼。
從 UIWebView 中獲取 Status Code ,比如 404 之類(lèi)的報(bào)錯(cuò)信息,可以使用蘋(píng)果官網(wǎng)提供的代碼
- - (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];
 - }
 - }
 
小結(jié):iPhone開(kāi)發(fā) 從UIWebView中獲取Status Code 實(shí)例教程的內(nèi)容介紹完了,希望本文對(duì)你有所幫助。
本文來(lái)自:http://www.cocoachina.com/iphonedev/sdk/2010/1202/2429.html















 
 
 

 
 
 
 