所以我有一个UITableViewCell
,我想删除tableView中的图像。但我也想从Parse数据库中删除给定的对象。
我将图像对象保存在在线Parse框架和Local Datastore
。
for i in images{
var imageNames = i.thumbnailImage
var imageFile = PFFile(data: UIImagePNGRepresentation(imageNames))
//Pin the objects here!!
var imageObject = PFObject(className: "img")
imageObject["theImg"] = imageFile
//imageObject["user"] = PFUser.currentUser()?.username
imageObject.pinInBackgroundWithName("imgs")
var objID = imageObject.objectId
imageObject.pinInBackgroundWithBlock({ (success, error) -> Void in
if error == nil{
println("Object Saved!!")
imageObject.save()
println(objID)
self.imagesFromParse.append(imageNames!)
self.tableView.reloadData()
} else {
println(error)
}
})
然后我在这里调用了删除UITableViewCell
函数 -
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
var cell:nudeCell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! nudeCell
if editingStyle == UITableViewCellEditingStyle.Delete{
if self.imagesFromParse.count >= 1{
self.imagesFromParse.removeAtIndex(indexPath.row)
//Here is where i want to delete the object from the localDatastore and the online framwork
}
}
}
问题是当我尝试在后台删除对象时。我不知道如何在给定的indexPath中获取要删除的特定对象ID。