title: Table view cell checkmark changes position when scrolling
body: <p>I am new to Swift. I have created a simple list in a tableview. When the user long presses on a row, that row will get checked. It's working perfectly fine. But when I scroll down, check mark changes its position. I also tried to store position in NSMutableSet. But still it's not working. Maybe I am doing something wrong.</p>
  
  <p>This is my code:</p>
  
  <p>This method gets called on long press.</p>
  
  <pre><code>func longpress(gestureRecognizer: UIGestureRecognizer)
  {
      let longpress = gestureRecognizer as! UILongPressGestureRecognizer
      let state = longpress.state
      let locationInview = longpress.location(in: tableview1)
      var indexpath=tableview1.indexPathForRow(at: locationInview)
  
      if(gestureRecognizer.state == UIGestureRecognizerState.began)
      {
          if(tableview1.cellForRow(at: indexpath!)?.accessoryType == 
          UITableViewCellAccessoryType.checkmark)
          {
              tableview1.cellForRow(at: indexpath!)?.accessoryType = 
                  UITableViewCellAccessoryType.none
          }
          else{
              tableview1.cellForRow(at: indexpath!)?.accessoryType = 
                  UITableViewCellAccessoryType.checkmark
          }
      }
  }
  </code></pre>