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()
}
}