1

I am trying to delete an image from parse using the REST API. To delete it I am using tableview and commitEditingStyle to have a slide and delete feature. But the problem is that it does not slide. I have read the docs and looked at numerous tutorials and I don't know why mine is not working. Below is the code for the tableview. Thank you!

    func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
        return true
    }
    func tableView(tableView: UITableView!, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath!) {
        println("Commit Editing Style \(editingStyle)")
    }

func tableView(tableView: UITableView!, editActionsForRowAtIndexPath indexPath: NSIndexPath!) -> [AnyObject]! {



    var deleteAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Delete", handler: {
        (action: UITableViewRowAction!, indexPath: NSIndexPath!) in
        println("Triggered delete action \(action) atIndexPath: \(indexPath)")
        return
    })

    return [deleteAction]
}


    func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
        if editingStyle == .Delete {


            var fileName = "uploaded_image.png"
            let applicationID = "appidwritten"
            let masterKey = "masterkeywritten"

            let request = NSMutableURLRequest(URL: NSURL(string: "https://api.parse.com/1/files/\(fileName)")!)
            request.HTTPMethod = "DELETE"
            request.setValue(applicationID, forHTTPHeaderField: "X-Parse-Application-Id")
            request.setValue(masterKey, forHTTPHeaderField: "X-Parse-Master-Key")
            NSURLSession.sharedSession().dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in
    println(response)
            }).resume()

}


}
Satsuki
  • 2,166
  • 5
  • 17
  • 33
  • Apart from the subject, i suggest to use Parse SDK rather than calling Parse APIs. :) – Akshit Zaveri Jul 01 '15 at 15:04
  • hello thank you for the comment, I am using the REST API since Parse will not let users delete PFFile. – Satsuki Jul 01 '15 at 15:05
  • See this SO: http://stackoverflow.com/questions/8983094/how-to-enable-swipe-to-delete-cell-in-a-tableview – KevinS Jul 01 '15 at 15:09
  • hello thank you for the comment, yes I have seen that stack overflow question and did not help with my issue. the slider does not even come out even I am returning true – Satsuki Jul 01 '15 at 16:09

0 Answers0