I want to create 2 button.when the buttons is pushed,it should make a phone call. ı wrote this code and it works but my problem is the buttons call same number.ı want to call different numbers.
can anyone fix my code ?
#define firstnumber @"1"
#define secondnumber @"2"
- (IBAction)first:(id)sender
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:firstnumber message:@"do you want to call?" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"ok", nil];
[alert show];
[alert release];
}
- (IBAction)second:(id)sender
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:secondnumber message:@"do you want to call?" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"ok", nil];
[alert show];
[alert release];
}
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
// the user cticlicked one of the OK/Cancel buttons
if (buttonIndex == 1)
{
NSLog(@"ok");
NSURL *url = [[NSURL alloc] initWithString:[NSString stringWithFormat:@"tel://%@", firstnumber]];
[[UIApplication sharedApplication] openURL:url];
[url release];
}
else
{
NSLog(@"cancel");
}
}
`
This should do it: