title: Swift: Using a variable to describe an UIViews
body: <p>I have multiple custom pop up views that I call (to set it up, animate the pop up and animate the dismiss) but I want to have one variable that I can replace in the multiple functions that can be set by a switch statement with one variable. So I don't have 4+ of every function with the same code but different uiView names. How is that done please?</p>
  
  <pre><code>var myPopupView:NotePopUpView!
  var myInformationPopUpView:InformationPopUpView!
  var myDatePopUpView:DatePopUpView!
  var myPainDiagramView:PainDiagramPopUpView!
  
  func notePopUpCalled() {
     if (myPopupView != nil) {
      self.myPopupView.view.removeFromSuperview()
     }
  
  // making different size pop up for different screens
    var popUpWidth = GlobalConstants.ScreenStats.screenWidth - 60
  
    if UIScreen.mainScreen().bounds.size.width &gt; 320 {
      if UIScreen.mainScreen().scale == 3 {
        popUpWidth = 320
      } else {
        popUpWidth = 320
      }
    } else {
      popUpWidth = 283
    }
  
  self.myPopupView = NotePopUpView(frame: CGRect(x: 20, y: 350, width: popUpWidth, height: 334))
  myPopupView.center = self.view.center
  self.view.addSubview(myPopupView)
  showAnimate()
  
  }
  </code></pre>