If have the app working when a custom UITableViewCell is tapped in the mainVC, i can edit the CoreData in the inputTableVC. Now i'am trying todo the same thing but then when the UITableViewRowAction "Edit" is tapped. The "Delete" function is already working.
Is there any way to implement the prepereForSegue or fetchRequest in the UITableViewRowAction?
Thanks in advance.
// 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]
}