Advertisement
undeadhip

Untitled

Jul 8th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. NSMutableArray *_displayedErrors;
  2. void errorAlert(NSString *text) {
  3.     if (!_displayedErrors) {
  4.         _displayedErrors = [[NSMutableArray alloc] init];
  5.     }
  6.    
  7.     if (text == nil) {
  8.         text = @"Unknown error";
  9.     }
  10.    
  11.     if ([_displayedErrors containsObject:text]) {
  12.         return;
  13.     }
  14.    
  15.     [_displayedErrors addObject:text];
  16.     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  17.         [_displayedErrors removeObject:text];
  18.     });
  19.    
  20.     UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error".localized message:text delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
  21.     [alertView show];
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement