Wednesday, April 6, 2011

.h file

#import <UIKit/UIKit.h>

@interface Caller_AppViewController : UIViewController {
IBOutlet UILabel *message;

}

- (IBAction)buttonPressed;

@property (nonatomic, retain) IBOutlet UILabel *message;
@end

Lesson 10 .M File

- (IBAction)buttonPressed;{
   
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel:65521111"]])
    {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:65521111"]];
    }
    else
    {
        message.text = @"Device not on cellular network";
        UIActionSheet *sheet1 = [[UIActionSheet alloc] initWithTitle:message.text delegate:self cancelButtonTitle:@"OK" destructiveButtonTitle:nil otherButtonTitles:nil];
        [sheet1 showInView:self.view];   
        [sheet1 release];
       
    }
   
}