Question

I want to do the following. I have an array of objects (businesses) and each business has its own details including their telephone numbers.

I know how to make a call in Objective-C but I don't know how to update the numbers dynamically. I have a Details class (.h and .m) and I have declared tel as a variable.

So to make a call I would use below as an example

-(IBAction)MakePhoneCall:(id)sender
{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:123456"]];
}

I use a DetailViewController so I have a list of businesses that gets populated and depending on the business selected, that business object is created. So for my tel I want to do the following:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:" + detail.tel]];

But this obviously doesnt work. Can anyone please tell me how this is done?

Was it helpful?

Solution

if you're making a call from your application and you want the user back into the application after the end of the call then use telprompt: instead of tel: like below

-(IBAction)MakePhoneCall:(id)sender
{
    NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@",detail.tel]];
    [[UIApplication sharedApplication] openURL:URL];
}

OTHER TIPS

I would create a [NSString stringWithFormat], then plug that in the "URLWithString".

-(IBAction)MakePhoneCall:(id)sender
{
NSString *string = [NSString stringWithFormat:@"tel:%@", detail.tel];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:string];
}

Hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top