title: Swift 3 Draggable UIButton
body: <p>Apologies as I'm still learning the basics of Swift.  </p>
  
  <p>I'm trying to move a button when I drag it which sounds simple.  I can't figure out how to pass along the sender information to the drag function so I can associate it with the button that is being dragged.  </p>
  
  <p>I create multiple one word buttons which are only text and attach a pan gesture recognizer to each of them:</p>
  
  <pre><code>let pan = UIPanGestureRecognizer(target: self, action: #selector(panButton(_:)))
  let word = UIButton(type: .system)
  word.addGestureRecognizer(pan)
  </code></pre>
  
  <p>I've created this function to trigger when the button is moved:</p>
  
  <pre><code>func panButton(sender: UIPanGestureRecognizer){
      if sender.state == .began {
          //wordButtonCenter = button.center // store old button center
      } else if sender.state == .ended || sender.state == .failed || sender.state == .cancelled {
          //button.center = wordButtonCenter // restore button center
      } else {
          let location = sender.location(in: view) // get pan location
          //button.center = location // set button to where finger is
      }
  }
  </code></pre>
  
  <p>I'm getting the following error:</p>
  
  <pre><code>Use of unresolved identifier 'panButton'
  </code></pre>