title: iOS dismiss UIAlertView beforing showing another
body: <p>I have a Utils class which shows UIAlertView when certain notifications are triggered. Is there a way to dismiss any open UIAlertViews before showing a new one?</p>
  
  <p>Currenty I am doing this when the app enters the background using</p>
  
  <pre><code>[self checkViews:application.windows];
  </code></pre>
  
  <p>on applicationDidEnterBackground</p>
  
  <pre><code>- (void)checkViews:(NSArray *)subviews {
      Class AVClass = [UIAlertView class];
      Class ASClass = [UIActionSheet class];
      for (UIView * subview in subviews){
          if ([subview isKindOfClass:AVClass]){
              [(UIAlertView *)subview dismissWithClickedButtonIndex:[(UIAlertView *)subview cancelButtonIndex] animated:NO];
          } else if ([subview isKindOfClass:ASClass]){
              [(UIActionSheet *)subview dismissWithClickedButtonIndex:[(UIActionSheet *)subview cancelButtonIndex] animated:NO];
          } else {
              [self checkViews:subview.subviews];
          }
      }
  }
  </code></pre>
  
  <p>This makes it easy on applicationDidEnterBackground as I can use application.windows</p>
  
  <p>Can I use the AppDelegate or anything similar to get all the views, loop through them and dismiss any UIAlertViews?</p>