     func reloadTasks() {
         //Reloads and saves tasks
         saveClasses()
+        loadTasks()
         tableView.reloadData()
     }
     


import UIKit

class TaskVC: UITableViewController, AddTaskDelegate, UIPopoverPresentationControllerDelegate {
    
    var classes: [JHSchoolClass]!
    var clas: JHSchoolClass!
    var tasksToDisplay: [JHTask]!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        title = clas.name
        
        setUp()
        
    }

        self.dismiss(animated: true, completion: nil)
    }
    
    @objc func navBarLongPress(sender: UILongPressGestureRecognizer? = nil) {
        if sender?.state == UIGestureRecognizerState.began {
            print("Changing display type...")
            changeDisplayType()
        }
    }
    
    func changeDisplayType() {
        if displayType == .NotCompleted {
            displayType = .All
        } else {
            displayType = .NotCompleted
        }
        reloadTasks()
    }
    
    func loadTasks() {
        //Get tasks to be displayed
        if displayType == .NotCompleted {
            tasks = incompletedTasks
        } else {
            tasks = clas.tasks
        }
    }
    
    func setUp() {
        //General UI set up at vc launch
        let button = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(addTask))
        navigationItem.rightBarButtonItem = button
        let longPress = UILongPressGestureRecognizer(target: self, action: #selector(navBarLongPress(sender:)))
        longPress.delegate = self
        navigationController?.navigationBar.addGestureRecognizer(longPress)
        
        //Get array of incompleted tasks
        incompletedTasks = [JHTask]()
        for t in clas.tasks {
            if !t.completed {
                incompletedTasks.append(t)
            }
        }
        loadTasks()
        
    }

