i trying handle specific nserrors
uialertview
none of codes in if statements called when webview didfailloadwitherror
called. below condition statement:
- (void)webview:(uiwebview *)webview didfailloadwitherror:(nserror *)error { loadfailedbool = yes; nslog(@"error code %ld", (long)[error code]); if ([error code] != -999) { //loading cancelled , 1 initiated. don't show alert return; } else if ([error code] == nsurlerrortimedout || [error code] == kcfurlerrortimedout) { //connection timed out uialertview *alert = [[uialertview alloc] initwithtitle:@"alert" message:@"network connection timed out" delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil, nil]; [alert show]; alert.tag = 1; } else if ([error code] == -1005) { //connection lost uialertview *alert = [[uialertview alloc] initwithtitle:@"alert" message:@"network connection host lost" delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil, nil]; [alert show]; alert.tag = 1; } else if ([error code] == kcfurlerrornotconnectedtointernet || [error code] == -1009) { //no internet connection nslog(@"error here"); uialertview *alert = [[uialertview alloc] initwithtitle:@"alert" message:@"looks not connected internet" delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil, nil]; [alert show]; alert.tag = 1; } else if ([error.domain isequaltostring:@"webkiterrordomain"] && error.code == 102) { return; } }
my question is, how condition called because log prints -1009 when there no internet. thanks
the thing never past line:
if ([error code] != -999) { return; }
so if error code -1009
, or anything -999
, it's late - have said return
, whole thing over. later code won't execute.