如果在 mainVC 中点击自定义 UITableViewCell 时应用程序正常工作,我可以在 inputTableVC 中编辑 CoreData。现在我正在尝试做同样的事情,但是当点击 UITableViewRowAction“编辑”时。“删除”功能已经开始工作。
有没有办法在 UITableViewRowAction 中实现 prepereForSegue 或 fetchRequest?
提前致谢。
// Mark- My current working Segue code
override public func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if segue.identifier == "EditRaptor" {
let customMainVCTableCell = sender as! CustomMainVCTableCell
let indexPath = tableView.indexPathForCell(customMainVCTableCell)
let addRaptorVC:AddRaptorVC = segue.destinationViewController as! AddRaptorVC
let addRaptor:AddRaptorCoreData = fetchedResultController.objectAtIndexPath(indexPath!) as! AddRaptorCoreData
addRaptorVC.addRaptor = addRaptor
}
}
// Mark- The TableViewRowAction that needs to be fixed
public func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? {
let managedObject:NSManagedObject = fetchedResultController.objectAtIndexPath(indexPath) as! NSManagedObject
var deleteAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Delete" , handler: {
(action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
self.managedObjectContext?.deleteObject(managedObject)
self.managedObjectContext?.save(nil)
})
var editAction = UITableViewRowAction(style: UITableViewRowActionStyle.Normal, title: "Edit" , handler: {
(action:UITableViewRowAction!, indexPath:NSIndexPath!) in
})
return [deleteAction,editAction]
}