Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 0.75 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. iPhone - How to handle errors at runtime
  2. [self kill];
  3. [OneClass exitWithFatalErrorMessage];
  4. return nil;
  5.  
  6. - (void) exitWithFatalErrorMessage:(NSString*)message
  7. {
  8.     UIAlertView* alert = [[UIAlertView alloc] initWithTitle:NSLocalizedStringFromTable(@"Error" @"ErrorMessages", @"") message:message delegate:self cancelButtonTitle:NSLocalizedStringFromTable(@"Understood", @"ErrorMessages", @"") otherButtonTitles: nil];
  9.     [alert show];
  10.     [alert release];
  11. }
  12.  
  13. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  14. {
  15.     // stop the normal running of the app, there is a situation that would prevent it
  16. }
  17.  
  18. - (void)kill
  19. {
  20.     self.member = nil;
  21.     self.member2 = nil;
  22.     ...
  23. }
  24.        
  25. [OneClass exitWithFatalErrorMessage:@"Message"];