views:

23

answers:

0

I'm able to initiate a call to a specific phone # via the logic below:

NSString* url = [[NSString alloc] initWithFormat:@"tel:%@", (telephoneNumber == nil) ? @"" : telephoneNumber];

if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:url]]) {
 [[UIApplication sharedApplication] openURL: [NSURL URLWithString:url]];
} else {
 // Build an alert with the reason for the failure
 NSString* errorMessage = [[NSString alloc] initWithFormat:@"Sorry, unable to initiate call.\ncanOpenUrl: %@ returned NO.\nDo not know why.\nThis device may not allow calls to be initiated.", url];
 UIAlertView* alert = [[UIAlertView alloc]
        initWithTitle:@"Unable to initiate telephone call"
        message:errorMessage
        delegate:nil
        cancelButtonTitle:@"OK"
        otherButtonTitles:nil];

 [alert show];
 [alert release];
 [errorMessage release];
}

But when I don't have a phone number the logic fails. I'd like to let the user key in a number themselves when I don't have a value for telephoneNumber. How can I do that?