4 つのタブ バー項目を持つ TabBarApplication があります。
3 番目のタブでは、CLLocationManager を使用して、ユーザーの場所などを特定します。
- (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;
}
}
しかし、タブを 4 番目に切り替えると、次のことが起こります。
次のメッセージを含む UIAlertView を取得します。
Unknown network error.
タブを切り替えると CLLocationManager は死にませんか? dealloc-method で [release]-method を呼び出しました。