1

I want to delete cell from the parse server so can anybody tell what should I write under func commiteditingstyle?

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let logCell:UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "Default")

    let Log:PFObject = self.LogData.objectAtIndex(indexPath.row) as! PFObject


    logCell.textLabel?.text = Log.objectForKey("Weight") as? String
    return logCell
}
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
    return true
}

override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
    // delete object from parse, remove from list


   }
}

1 Answer 1

1

When you wish to delete an object from the Parse cloud, the method deleteInBackground() should be used.

let Log:PFObject = self.LogData.objectAtIndex(indexPath.row) as! PFObject
Log.deleteInBackground()

You'd also want to remove the cell from the tableView itself, if isn't done automatically. You'd need to delete the PFObject from LogData first, and then reload the table. Good luck.

Sign up to request clarification or add additional context in comments.

3 Comments

can u please tell me if want to delete all cells with only one button like Clear list how can I do this using parse
Create a loop iterating through all PFObjects in LogData, and delete every one of them like so.
can you please give me some hint by writing some code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.