views:

8

answers:

1

Hi!

I have a TabBarApplication with four tab bar items.

My third tab uses a CLLocationManager to locate where the user are and so forth.

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {

[locationManager stopUpdatingLocation];
NSLog(@"error%@",error);
switch([error code])
{
    case kCLErrorNetwork:
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Please check your network connection or that you are not in airplane mode." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
        [alert show];
        [alert release];
    }
        break;
    case kCLErrorDenied:{
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"You have denied to allow Berns to get your location. " delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
        [alert show];
        [alert release];
    }
        break;
    default:
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Unknown network error." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
        [alert show];
        [alert release];
    }
        break;
}

}

But when I switch tab to the fourth, this happends:

I get an UIAlertView with the message:

Unknown network error.

Doesn't the CLLocationManager die when switching tab? I have called [release]-method in the dealloc-method.

A: 

I think it had to do with that I didn't implemented Reachability to check for network connection.

This is also a demand in the App Store Guidelines (or what you call it).

So the answer is: Check for Internet connection with Reachability and inform the user if the application demands this.

Fernando Redondo