     
     // MARK: Properties
     
+    /// Any Realm notification tokens that are active
     private var notificationTokens: [NotificationToken] = [NotificationToken]()
     
+    /// The semesters, which are the sections for the tableview
     private var semesters: [Semester] {
         get {
             return generateSemesters()
         }
     }
     
+    /// All the classes saved in Realm, grouped by their semesters
     private var classes: [Results<Class>] = [Results<Class>]()
+    
+    /// Classes filtered by search text from the `searchController`
+    private var filteredClasses: Results<Class>?
+    
+    /// The search controller used to filter the table view
+    private lazy var searchController: UISearchController = {
+        let controller = UISearchController(searchResultsController: nil)
+        controller.searchBar.delegate = self
+        controller.dimsBackgroundDuringPresentation = false
+        controller.searchBar.placeholder = "Search classes"
+        return controller
+    }()
     
     // MARK: View Handeling
     
     override func viewDidLoad() {
         super.viewDidLoad()
         
-        // Setup delegation a
+        // Setup search bar and titles
         if #available(iOS 11.0, *) {
             navigationController?.navigationBar.prefersLargeTitles = true
-        }
+            navigationItem.searchController = searchController
+        } else {
+            searchController.searchBar.barTintColor = UIColor(red: 0.337, green: 0.337, blue: 0.376, alpha: 1.00)
+            tableView.contentOffset = CGPoint(x: 0, y: tableView.contentOffset.y + searchController.searchBar.frame.height)
+            tableView.tableHeaderView = searchController.searchBar
+        }
+        
         splitViewController?.delegate = self
         splitViewController?.preferredDisplayMode = .allVisible
         tableView.scrollsToTop = true

            }
            
            // Collapse any edit actions for the tableview, so theyre not opened when returning
            self.tableView.isEditing = false
            
        case .onboarding:
            break
        }
    }
}


    }
}

extension ClassesTableViewController: UISearchBarDelegate {
    func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
        guard searchText != "" else {
            self.searchController.isActive = false
            self.tableView.reloadData()
            self.reloadEmptyState()
            return
        }
        
        // Update classes array to filter for name
        self.filterClasses(for: searchText)
        self.tableView.reloadData()
    }
    
    func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
        self.searchController.isActive = false
        self.tableView.reloadData()
        self.reloadEmptyState()
    }
}

// MARK: Segues

extension ClassesTableViewController: Segueable {
