0

didFailLoadWithError being called only for iOS7.
This method is not called for iOS6.

The error logged is:

ERROR : Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)" UserInfo=0xcd0e200 {NSErrorFailingURLKey=bsp.gov.ph/statistics/sdds/exchrate.htm, NSErrorFailingURLStringKey=bsp.gov.ph/statistics/sdds/exchrate.htm}

The error code -999 apparently is a URL Cancelled request but I am using the same code for iOS6 and works perfectly fine.

Why does it show an error for ios7?


The code I am using is:

- (void)viewDidLoad
{
     [super viewDidLoad];                
     isFirstTime=TRUE;                

     ratesArray=[[NSArray alloc]initWithObjects:@"In",@"USD",@"JPY",@"GBP",@"HKD",@"CAD",@"SGD",@"AUD",@"SAR",@"THB",@"AED",@"CNY",@"KRW",@"EUR",@"MYR",@"TWD", nil];

     NSLog(@"rates.count = %d",ratesArray.count);
     defaults = [NSUserDefaults standardUserDefaults];
     [self loadServerData];
}

-(void)loadServerData
{
    GeneralClass *gen=[GeneralClass retrieveSingleton];        
    euroRatesArray =[[NSMutableArray alloc]init];
    [euroRatesArray addObject:@"EURO"];

    usRatesArray =[[NSMutableArray alloc]init];
    [usRatesArray addObject:@"US"];

    phpRatesArray =[[NSMutableArray alloc]init];
    [phpRatesArray addObject:@"PHP"];

    self.navigationController.navigationBar.hidden=TRUE;

    if ([gen checkNetworkConnection] ) {
        [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

        //Create a URL object.
        NSURL *url = [NSURL URLWithString:@"http://www.bsp.gov.ph/statistics/sdds/exchrate.htm"];

        //URL Requst Object
        NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

        //Load the request in the UIWebView.
        [webPage loadRequest:requestObj];
    } else {
        defaults = [NSUserDefaults standardUserDefaults];
        NSData *data = [defaults objectForKey:kExchanteRatesKey];
        NSArray *contentArray = [NSKeyedUnarchiver unarchiveObjectWithData:data];

        lblDate.text=[defaults objectForKey:kExchanteRateDate];

        if (contentArray.count>0) {

            for (int i=1; i<contentArray.count-1; i++) {
                RateClass *rate=(RateClass *)[contentArray objectAtIndex:i];
                [euroRatesArray addObject:(rate.text2.length>0 ? rate.text2:@"")];
                [usRatesArray addObject:(rate.text3.length>0 ? rate.text3:@"")];
                [phpRatesArray addObject:(rate.text4.length>0 ? rate.text4:@"")];
            }
        }

        //NSLog(@"euroRatesArray = %@",euroRatesArray);
        //NSLog(@"usRatesArray = %@",usRatesArray);
        //NSLog(@"phpRatesArray = %@",phpRatesArray);

        [activity setHidden:TRUE];
        [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    }
}

-(void)webViewDidFinishLoad:(UIWebView *)webView
{
    [self hideActivityBar];
}

-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    [self hideActivityBar];
}

-(void) hideActivityBar
{
    [self htmlParse];
}

-(void)htmlParse
{
    //NSString *html = [webPage stringByEvaluatingJavaScriptFromString: @"document.getElementById('exchrate_28426').innerHTML"];
    //NSString *html = [webPage stringByEvaluatingJavaScriptFromString: @"document.getElementsByClassName('xl6528426')[0].innerHTML"];
    NSString *html = [webPage stringByEvaluatingJavaScriptFromString:@"document.body.innerText"];
    NSArray *array=[html componentsSeparatedByString:@"\n"];
    NSLog(@"array.count = %d",array.count);
    int checkRateIndex=1;
    int index=212;
    NSUserDefaults *standardUserDefaults=[NSUserDefaults standardUserDefaults];
}
Shaik Riyaz
  • 11,204
  • 7
  • 53
  • 70
koherent
  • 370
  • 1
  • 3
  • 19
  • are you logging any errors you receive? – Wain Jan 06 '14 at 11:47
  • ERROR : Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)" UserInfo=0xcd0e200 {NSErrorFailingURLKey=http://www.bsp.gov.ph/statistics/sdds/exchrate.htm, NSErrorFailingURLStringKey=http://www.bsp.gov.ph/statistics/sdds/exchrate.htm} – koherent Jan 06 '14 at 13:17
  • did you check these similar questions? might help you identify the issue yourself: [link1](http://stackoverflow.com/questions/16073519/nsurlerrordomain-error-code-999-in-ios) & [link2](http://stackoverflow.com/questions/13860401/ignoring-nsurlerrordomain-error-999-does-not-work-in-uiwebview) – staticVoidMan Jan 07 '14 at 06:01

0 Answers0