Quote:
Originally Posted by james4026
Like this?
- (void)tableView  UITableView *)tableView didSelectRowAtIndexPath  NSIndexPath *)indexPath {
[[UIApplication sharedApplication openURL: [NSURL URLWithString:@"tel://"];
I assume that something needs to go with "tel://" so that it knows where to get the number from?? The numbers are in an NSarray called cabNumbers if that helps.
|
Assuming your table view has a row for every entrain your cabNumbers array, you could use code like this:
Code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString* phone = [cabNumbers objectAtIndex: indexPath.row];
NSString* urlString = [NSString stringWithFormat: @"tel://%@", phone];
[[UIApplication sharedApplication openURL: [NSURL URLWithString: urlString];
}
The trick is the "stringWithFormat" method. It takes a format string as a parameter, and lets you combine strings with other strings, convert numbers to strings, and do various other types of format conversions. The "%@" in the format string above means "replace %@ with the contents of an object." When the object is a string, it replaces the "%@" with the contents of the string.
Do a search for "String Format Specifiers" in the XCode help system, and look for the section in the String Programming Guide titled "String Format Specifiers" for more information on using string formatting.