Search code examples
iphoneuialertview

UIAlertView close the App


in my project my app first tries to connect to the internet, but now i have to check if there is an connection available! so i made an if, else within an UIAlertView in the else part!

but how can i close the whole app on a click on the following button?

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Keine Internetverbindung" message:@"Es konnte keine Verbindung zu www.sip.de hergestellt werden!" delegate:nil cancelButtonTitle:@"Schliessen" otherButtonTitles:nil];

thank you all for helping beforehand

greets Marco


Solution

  • .h file

    @interface UntitledViewController : UIViewController < UIAlertViewDelegate > { }

    .m file

    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Keine Internetverbindung" message:@"Es konnte keine Verbindung zu www.sip.de hergestellt werden!" delegate:nil cancelButtonTitle:@"Schliessen" otherButtonTitles:nil];
    
        [alert setDelegate:self];
        [alert show];
        [alert release];
    }
    
    - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
        exit(0);
    }
    

    hope this helps