I'm trying to call function from one class in view controller:

```
var rate = RateMyApp.sharedInstance 
rate.showRatingAlert()

```

and in RateMyApp class I call alert view:

```
 var window: AnyObject = UIApplication.sharedApplication().keyWindow!;
        var vc = window.rootViewController;
      vc?!.presentViewController(alert, animated: true, completion: nil)

```

However, the alert is not shown and there is a kind of warning:

```
 Warning: Attempt to present <UIAlertController: 0x15fe3dcf0> on <drawtext.ViewController: 0x16002a800> whose view is not in the window hierarchy!

```

That happens from time to time, if one hides the app and then opens it again several times, the alert sometimes is shown.

What can cause such strange behavior?