         super.viewDidLoad()
         
         self.tableView.tableFooterView = UIView(frame: CGRectZero)
+        self.tableView.allowsMultipleSelectionDuringEditing = false
+        
+        self.tabBarController?.delegate = self
         
         try! fetchedResultsController.performFetch()
         

import CoreData
import JSQCoreDataKit

class TasksViewController: UITableViewController, NSFetchedResultsControllerDelegate {
    
    var coreDataStack: CoreDataStack?
    

    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        self.performSegueWithIdentifier("TasksToEditTask", sender: self.fetchedResultsController.fetchedObjects![indexPath.row])
    }
    
    override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
        if editingStyle == .Delete {
            // Delete the task
            
            let taskToDelete = [self.fetchedResultsController.fetchedObjects![indexPath.row] as! Task]
            deleteObjects(taskToDelete, inContext: self.coreDataStack!.managedObjectContext)
            
            // Save the context
            
            let saveResult = saveContextAndWait(self.coreDataStack!.managedObjectContext)
            if !saveResult.success {
                print("Couldn't save the context: \(saveResult.error)")
            }
        }
    }
    
    func tabBarController(tabBarController: UITabBarController, didSelectViewController viewController: UIViewController) {
        self.tableView.setEditing(false, animated: true)
    }

    @IBAction func addButtonPressed(sender: AnyObject) {
        self.performSegueWithIdentifier("TasksToNewTask", sender: nil)
        self.tableView.setEditing(false, animated: true)
    }
    
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
