what i am attempting to do is when a user touches a butotn, it dials a number
i was going to use the open url through safari approach to dial out
and this code:
so do i do something like IBaction ...i think thats the wrong syntax
but do i use the button press syntax code, to execute the code above?
i was going to use the open url through safari approach to dial out
and this code:
Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after app launch
// Schedule -showUsageAlertDialog on the next cycle of the event loop to give the
// application:handleOpenURL: delegate method an opportunity to handle an incoming URL.
// If that delegate method is called, it sets the showUsageAlert to NO, which prevents
// the usage dialog from being shown.
showUsageAlert = YES;
[self performSelector:@selector(showUsageAlertDialog) withObject:nil afterDelay:0.0];
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
showUsageAlert = NO;
// You should be extremely careful when handling URL requests.
// You must take steps to validate the URL before handling it.
if (!url) {
// The URL is nil. There's nothing more to do.
return NO;
}
NSString *URLString = [url absoluteString];
NSString *message = [NSString stringWithFormat:@"The application received a request to open this URL: %@. Be careful when servicing handleOpenURL requests!", URLString];
UIAlertView *openURLAlert = [[UIAlertView alloc] initWithTitle:@"handleOpenURL:" message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[openURLAlert show];
[openURLAlert release];
if (!URLString) {
// The URL's absoluteString is nil. There's nothing more to do.
return NO;
}
// Your application is defining the new URL type, so you should know the maximum character
// count of the URL. Anything longer than what you expect is likely to be dangerous.
NSInteger maximumExpectedLength = 50;
if ([URLString length] > maximumExpectedLength) {
// The URL is longer than we expect. Stop servicing it.
return NO;
}
return YES;
}
- (void)showUsageAlertDialog
{
if (showUsageAlert) {
NSString *message = @"To demonstrate how this application handles a URL request for the new URL type that it registers, enter a URL in Safari that begins the with scheme of the URL type (launchme://) and press the Go button.";
self.usageAlertView = [[UIAlertView alloc] initWithTitle:@"Usage" message:message delegate:self cancelButtonTitle:@"Launch Safari" otherButtonTitles:nil];
[self.usageAlertView show];
}
}
- (void)dismissUsageAlert
{
[self.usageAlertView dismissWithClickedButtonIndex:-1 animated:YES];
}
- (void)modalViewCancel:(UIAlertView *)alertView
{
[alertView release];
}
- (void)modalView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex != -1) {
// Open Safari only if the user clicked the 'Launch Safari' button, but not if this
// delegate method is called by UIKit to cancel it. In that case, buttonIndex is -1.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.apple.com"]];
}
[alertView release];
}
- (void)dealloc {
[window release];
[super dealloc];
}
so do i do something like IBaction ...i think thats the wrong syntax
but do i use the button press syntax code, to execute the code above?
Code:
- (IBAction)dialnum { code here } end