自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

iPhone開發(fā) 從UIWebView中獲取Status Code實例教程

移動開發(fā) iOS
本文介紹的是從UIWebView中獲取Status Code 實例教程,基于代碼實現(xiàn),我們一起來看內(nèi)容。

iPhone開發(fā) 從UIWebView中獲取Status Code 實例教程是本文要介紹的內(nèi)容,本文是基于代碼實現(xiàn),內(nèi)容不多,我們來看實現(xiàn)代碼。

從 UIWebView 中獲取 Status Code ,比如 404 之類的報錯信息,可以使用蘋果官網(wǎng)提供的代碼

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

小結(jié):iPhone開發(fā) 從UIWebView中獲取Status Code 實例教程的內(nèi)容介紹完了,希望本文對你有所幫助。

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

責(zé)任編輯:zhaolei 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2014-08-26 11:46:46

QtAndroid實例教程

2009-09-18 11:44:05

Scala實例教程Kestrel

2011-08-17 10:09:25

iPhone開發(fā)UIWebViewTouch事件

2013-01-04 16:17:33

Android開發(fā)圖像特效圖像處理

2019-06-17 15:25:17

expandunexpandLinux

2010-08-17 11:02:45

DIV CSS實例教程

2011-07-27 17:41:35

Objective-C Xcode

2009-09-08 14:18:35

NFS服務(wù)器

2011-07-25 16:03:47

XCode 編譯

2009-07-30 14:18:02

ASP.NET實例教程

2010-08-25 17:08:18

實例教程

2013-01-14 17:05:55

UCUI設(shè)計菜單欄

2011-08-22 15:15:49

iPhone開發(fā)NSMutableAr排序

2011-07-25 18:02:51

iPhone LibFetion 移植

2011-08-10 15:48:10

iPhone網(wǎng)絡(luò)

2013-07-25 14:44:48

sqlite實例教程iOS開發(fā)學(xué)習(xí)sqlite打造詞典

2010-06-18 15:55:47

UML建模

2013-08-15 09:14:55

2011-08-08 16:56:44

iPhone 字符處理 視圖

2011-08-08 18:26:52

UIWebView圖片
點贊
收藏

51CTO技術(shù)棧公眾號