0

UIWebViewで発生する可能性のあるエラーのカテゴリはありますか?私のアプリでは、URLの読み込み中に発生した実際のエラーを表示する必要があります。didFailLoadWithErrorメソッドでエラーを出力できますが、エラーについての長い説明は次のようになります。

didFailLoadWithError Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo=0x895fb10 {NSErrorFailingURLStringKey=https://mobilelogin.bwanet.ca/mdninput.html?csphostid=J13y8E9t000Mb3ZK00001H7R, NSErrorFailingURLKey=https://mobilelogin.bwanet.ca/mdninput.html?csphostid=J13y8E9t000Mb3ZK00001H7R, NSLocalizedDescription=A server with the specified hostname could not be found., NSUnderlyingError=0x8c68f20 "A server with the specified hostname could not be found."}

これらの考えられるエラーをどのように分類し、「指定されたホスト名が見つかりませんでした」、「URLタイムアウトエラー」などのように表示したいと思います。

4

2 に答える 2

1

この投稿では、考えられるエラーコードのリストを見つけることができます。これは、特定のエラー文字列を使用して分類するのに役立ちます。StoreKitを使用した文書化されていないNSURLErrorDomainエラーコード(-1001、-1003、および-1004)

于 2012-07-26T09:20:34.717 に答える
0

さて、didFailWithErrorメソッドで

if (error.code==NSURLErrorTimedOut) {

      errorReason=@"URL Time Out Error ";

   }
    else if (error.code==NSURLErrorCannotFindHost) {
      errorReason=@"Cannot Find Host ";

   }
       else if (error.code==NSURLErrorCannotConnectToHost) {
           errorReason=@"Cannot Connect To Host";

    }
             else if (error.code==NSURLErrorNetworkConnectionLost) {
               errorReason=@"Network Connection Lost";

       }
                   else if (error.code==NSURLErrorUnknown) {
                        errorReason=@"Unknown Error";

             }
                               else {
                                   errorReason=@"Loading Failed";

                   }
 UIAlertView *errorAlert=[[UIAlertView alloc]initWithTitle:errorReason message:@"Redirecting to the server failed. do you want to EXIT the app"  delegate:self cancelButtonTitle:@"EXIT" otherButtonTitles:@"RELOAD", nil];


  [errorAlert show];
  [errorAlert release];
于 2012-07-30T08:36:12.713 に答える