title: Delete a row from a class in Parse - In Swift
body: <p>I'm trying to make some voting buttons for my film app.</p>
  
  <p>I use Parse, and I've created a new class called <code>Votes_Up</code>. In this class their are 2 columns: <code>User_Voting</code> and <code>Film_VotedFor</code>. </p>
  
  <p>My code below is actioned when the button is pressed. It takes the currentUser and the film object that the button has been pressed against, and adds them to Parse. My database looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/kQIAz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kQIAz.png" alt="enter image description here"></a>   </p>
  
  <p><strong>What I need</strong></p>
  
  <p>so they way it currently works, if the user presses the vote button, it adds the info to the DB and adds 1 to the count. When the user presses it again, it just updates the count by taking 1 away. </p>
  
  <p>I would also want to remove the row it would have added to the database, By the User that voted for it.  How can I do this??</p>
  
  <p><strong>My code:</strong></p>
  
  <pre><code>@IBAction func upVoteButton(sender: UIButton) {
  
      let hitPoint = sender.convertPoint(CGPointZero, toView: self.tableView)
      let hitIndex = self.tableView.indexPathForRowAtPoint(hitPoint)
      let object = objectAtIndexPath(hitIndex)
  
      if PFUser.currentUser() != nil {
  
          if userPressedUpButton == false {
  
              userPressedUpButton = true
  
              let voteUp = PFObject(className: "Votes_Up")
              voteUp["User_Voting"] = PFUser.currentUser()
              voteUp["Film_VotedFor"] = object!
  
              object!.incrementKey("UpVoteCount")
              object!.saveInBackground()
  
              voteUp.saveInBackgroundWithBlock({ (success, error) in
  
                  if success == true {
  
                      // Object(s) was/were successfully saved
  
                  } else if error != nil {
  
                      // Display an alert to the user
  
                  } else {
  
                      // Display an alert to the user - something went wrong
  
                  }
  
              })
  
          } else {
  
              userPressedUpButton = false
  
             // I need to removed the row from the class here that was added, as the user has retracted their vote!
  
              object!.incrementKey("UpVoteCount", byAmount: -1)
              object!.saveInBackground()
  
          }
  
      } else {
  
          // No user is logged in so they can't vote
          performSegueWithIdentifier("Votes_LoginPopup", sender: self)
  
      }
  
      self.tableView.reloadData()
  
  }
  </code></pre>