       let when = dispatch_time(DISPATCH_TIME_NOW, Int64(duration * Double(NSEC_PER_SEC)))
       dispatch_after(when, dispatch_get_main_queue()) { [weak self] in
         // only dismiss when we it's the same notice
-        if self?.currentNoticeView === view {
+        if self?.currentNotice?.view === view {
           self?.dismissCurrentNotice()
         }
       }

import Foundation
import UIKit

public class NoticeWindow : UIWindow {

  /// pending notice
  private var pendingNoticeView: UIView?

  /// current notice view that is presented
  private var currentNoticeView: UIView?

  public func presentView(view: UIView, duration: NSTimeInterval? = 5, animated: Bool = true, completion: (() -> Void)? = nil) {

    if currentNoticeView != nil {
      pendingNoticeView = view

      dismissCurrentNotice(animated) {[weak self] in
        if let pendingView = self?.pendingNoticeView {
          self?.showView(pendingView, duration:  duration, animated: animated, completion: completion)
          self?.pendingNoticeView = nil
        }
      }

    } else {
      showView(view, duration: duration, animated: animated, completion: completion)
    }
  }

  private func showView(view: UIView, duration: NSTimeInterval? = 5, animated: Bool = true, dismissOnTouch: Bool = true, completion: (() -> Void)? = nil) {

    if dismissOnTouch {
      view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "noticeTouched"))
    }

    currentNoticeView = view
    addSubview(view)

    view.translatesAutoresizingMaskIntoConstraints = false

    addConstraints([
      NSLayoutConstraint(item: view, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: view.superview, attribute: NSLayoutAttribute.Left, multiplier: 1, constant: 0),
      NSLayoutConstraint(item: view, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: view.superview, attribute: NSLayoutAttribute.Top, multiplier: 1, constant: 0),
      NSLayoutConstraint(item: view, attribute: NSLayoutAttribute.Right, relatedBy: NSLayoutRelation.Equal, toItem: view.superview, attribute: NSLayoutAttribute.Right, multiplier: 1, constant: 0)
      ])

    view.layoutIfNeeded()


      CATransaction.setCompletionBlock(complete)
      let animation = CABasicAnimation(keyPath: "transform.translation.y")
      animation.duration = 0.25
      animation.toValue = position == .Top ? -noticeView.frame.size.height : +noticeView.frame.size.height
      animation.removedOnCompletion = false
      animation.fillMode = kCAFillModeForwards

