title: Warning: Attempt to present <UIAlertController: 0x7facd3946920> on <...> which is already presenting (null)
body: <p>I have a long press gesture set on a <code>UITableView</code> that presents a <code>UIAlertController</code> containing the cell's text. When the <code>UIAlertController</code> is presented I get this warning: </p>
  
  <pre><code>Attempt to present &lt;UIAlertController: 0x7fd57384e8e0&gt;  on &lt;TaskAppV2.MainTaskView: 0x7fd571701150&gt; which is already presenting (null)
  </code></pre>
  
  <p>From my understanding, MainTaskView (the <code>UITableView</code>) is already presenting a view, so it shouldn't present a second view, the <code>UIAlertController.</code> So I tried <a href="https://stackoverflow.com/q/28270282/3711622">this</a> solution from a similar question. It does not work as I get the same warning. What can I do to solve this warning? See below for code:</p>
  
  <pre><code>func longPressedView(gestureRecognizer: UIGestureRecognizer){
  
      /*Get cell info from where user tapped*/
      if (gestureRecognizer.state == UIGestureRecognizerState.Ended) {
          var tapLocation: CGPoint = gestureRecognizer.locationInView(self.tableView)
  
          var tappedIndexPath: NSIndexPath? = self.tableView.indexPathForRowAtPoint(tapLocation)
          if (tappedIndexPath != nil) {
              var tappedCell: UITableViewCell? = self.tableView.cellForRowAtIndexPath(tappedIndexPath!)
              println("the cell task name is \(tappedCell!.textLabel!.text!)")
          } else {
              println("You didn't tap on a cell")
          }
      }
  
      /*Long press alert*/
      let tapAlert = UIAlertController(title: "Long Pressed", message: "You just long pressed the long press view", preferredStyle: UIAlertControllerStyle.Alert)
      tapAlert.addAction(UIAlertAction(title: "OK", style: .Destructive, handler: nil))
      /*
      if (self.presentedViewController == nil) {
          self.presentViewController(tapAlert, animated: true, completion: nil)
      } else {
          println("already presenting a view")
      } */
  
      self.presentViewController(tapAlert, animated: true, completion: nil)
      println("presented")
  }
  </code></pre>
  
  <p>Console output: </p>
  
  <pre><code>presented
  You didn't tap on a cell
  2015-05-19 22:46:35.692 TaskAppV2[60765:3235207] Warning: Attempt to present &lt;UIAlertController: 0x7fc689e05d80&gt;  on &lt;TaskAppV2.MainTaskView: 0x7fc689fc33f0&gt; which is already presenting (null)
  presented
  </code></pre>
  
  <p>For some reason, both pieces of code are executing in the if statement when the long press gesture happens. The alert is presented and the text is printed to the console. Is this an issue?</p>
  
  <p><strong>Edit: As Matt said, I didn't have all my code in the scope of the gesture recognizer test. Moving that in fixed my problem. The code outside of the test was being executed twice, resulting in the <code>UIAlertController</code> being presented twice.</strong></p>