Reputation: 171
My table view is divided in two sections : completed tasks and to do.
When I hit delete I want the to do task in the completed task and vice versa.
This is my viewDidAppear:
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
}
and this my commit:
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
let thisTask = fetchedResultsController.objectAtIndexPath(indexPath) as! TaskModel
if indexPath.section == 0 {
thisTask.completed = true
}
else {
thisTask.completed = false
}
(UIApplication.sharedApplication().delegate as! AppDelegate).saveContext()
}
this the controllerDidChange:
func controllerDidChangeContent(controller: NSFetchedResultsController) {
tableView.reloadData()
}
Upvotes: 0
Views: 34
Reputation: 359
Check to see if the tableView
's dataSource and delegate properties are set. Other than that you could try this:
func controllerWillChangeContent(controller: NSFetchResultsController) {
tableView.beginUpdates();
}
func controllererDidChangeContent(controller: NSFetchResultsController) {
tableView.endUpdates();
}
Upvotes: 1