我无法弄清楚为什么我在操作表方法的下面一行中不断收到 EXC_BAD_ACCESS 错误:
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:numberFinal]];
我添加了我的代码,但我只是不明白为什么它被过度发布。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
number = [[results objectAtIndex:indexPath.row]objectForKey:@"phone"];
number = [number stringByReplacingOccurrencesOfString:@"-" withString:@""];
numberFinal = [NSString stringWithFormat:@"tel:%@",number];
//tel:1234567890
NSLog(@"NUMBER:%@",numberFinal);
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UIAlertView *alert2 = [[[UIAlertView alloc]initWithTitle:@"Call" message:@"Call This Person?" delegate:self cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil]autorelease];
alert2.tag = kAlertViewTwo;
[alert2 show];
// [alert2 release];
}
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
// the user clicked one of the OK/Cancel buttons
if(actionSheet.tag == kAlertViewOne) {
if (buttonIndex == 0)
{
}else{
}
}
else if(actionSheet.tag == kAlertViewTwo) {
if (buttonIndex == 0)
{
//ok button clicked - close alert
}
else
{
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:numberFinal]];
}
}
}