       println("An error Occured \(error)")
     }
   }
+  
+  func controllerDidChangeContent(controller: NSFetchedResultsController) {
+    self.tableView.reloadData()
+  }
 }

    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    
    self.tableView.dataSource = self
    self.tableView.delegate = self
  }

extension ViewController: UITableViewDataSource
{
  func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return fetchedResultsController.sections!.count
  }
  
  func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    let sectionInfo = self.fetchedResultsController.sections![section] as! NSFetchedResultsSectionInfo
    return sectionInfo.numberOfObjects
  }
  
  func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    
    let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell
    let task = self.fetchedResultsController.objectAtIndexPath(indexPath) as! Task
    
    cell.textLabel!.text = task.titleName
    
    if task.isCompleted == true {
      cell.backgroundColor = UIColor(red: 0.80, green: 0.93, blue: 0.84, alpha: 1.0)
    } else {
      cell.backgroundColor = UIColor(red: 0.93, green: 0.80, blue: 0.80, alpha: 1.0)
    }
    
    return cell
  }
}

