   
   @IBAction func addButtonTapped(sender: UIBarButtonItem) {
     performSegueWithIdentifier("showTaskAdd", sender: self)
+  }
+  
+  // Helper
+  func taskFetchRequest () -> NSFetchRequest {
+    let fetchRequest = NSFetchRequest(entityName: "TaskModel")
+    let sortDescriptor = NSSortDescriptor(key: "date", ascending: true)
+    fetchRequest.sortDescriptors = [sortDescriptor]
+    
+    return fetchRequest
+  }
+  
+  func getFetchedResultsController() -> NSFetchedResultsController {
+    fetchedResultsController = NSFetchedResultsController(fetchRequest: taskFetchRequest(), managedObjectContext: managedObjectContext, sectionNameKeyPath: nil, cacheName: nil)
   }
 }
 

//

import UIKit

class ViewController: UIViewController {
  
  @IBOutlet weak var tableView: UITableView!
  
  var baseArray: [[TaskModel]] = []
  
  override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
  }
  
  override func viewDidAppear(animated: Bool) {

    return [deleteButton]
  }
}

// MARK: - NSFetchedResultsControllerDelegate
extension ViewController: NSFetchedResultsControllerDelegate {
  
}
