iPhone開發(fā) 從UIWebView中獲取Status Code實例教程
作者:佚名
本文介紹的是從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)提供的代碼
- - (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開發(fā) 從UIWebView中獲取Status Code 實例教程的內(nèi)容介紹完了,希望本文對你有所幫助。
本文來自:http://www.cocoachina.com/iphonedev/sdk/2010/1202/2429.html
責(zé)任編輯:zhaolei
來源:
互聯(lián)網(wǎng)