Reputation: 3693
I want to implement a contact us page where there are few phone numbers, and i want to call the number when the user clicks on them. So i decided to create buttons with the phone number as their title.
For the button click methods i have something like this
-(IBAction)numberClicked:(id)sender;
For initiation a call i know i can use this
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", phoneNumber]]];
My question is how should i modify the method so that it can take the phone number(title of te button) as argument.
Help would be appreciated.
Upvotes: 0
Views: 157
Reputation: 170829
Try
NSString *phoneNumber = [sender currentTitle];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", phoneNumber]]];
Upvotes: 1