I tried to dial a number with the phone app after the user click on a button on a UIAlertview. The phone app did open, but the original app crashed right after clicking the butt
The crash is happening due to this code. [self release];
.
When you call self
release
the view in which the alert is displayed will released and deallocated, not the alertView. That's the cause of crash.
You are already releasing the alertViews memory in the dialButtonPressed:
method using [message autorelease];
So no need to release the alertView again in clickedButtonAtIndex
. So change the method like:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if(alertView.tag == 0 && buttonIndex == 1)
{
NSURL *phoneLinkURL = [NSURL URLWithString:phoneLinkString];
[[UIApplication sharedApplication] openURL:phoneLinkURL];
}
message = nil;
}