             return "Error"
         }
     }
-
+    
     override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
         if searchController.active && searchController.searchBar.text != "" {
             return filteredScheduleItems.count

        }
        
        self.tableView.scrollToRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 0), atScrollPosition: UITableViewScrollPosition.Top, animated: true)
     }
    
    override func viewWillAppear(animated: Bool) {
        for scheduleCell in tableView.visibleCells as! [ScheduleTableViewCell] {
            guard let indexPath = tableView.indexPathForCell(scheduleCell) else {
                return
            }
            
            var scheduleItem: Schedule? = nil
            
            if searchController.active && searchController.searchBar.text != "" {
                scheduleItem = filteredScheduleItems[indexPath.row]
            } else if scheduleItems[indexPath.section].count > indexPath.row {
                scheduleItem = scheduleItems[indexPath.section][indexPath.row]
            }
            
            if let foundScheduleItem = scheduleItem {
                scheduleCell.starButton.selected = foundScheduleItem.starred
            }
        }
        
        super.viewWillAppear(animated)
    }
    
    override func viewDidAppear(animated: Bool) {
        if tableView.numberOfRowsInSection(0) > 0 {
            scrollToNearestCell()
        }

        super.viewDidAppear(animated)
    }

    // MARK: - Table view data source

    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        if searchController.active && searchController.searchBar.text != "" {
            return 1

    
    func sortScheduleItems(starredOnly starredOnly: Bool) {
        var thursdayShows = [Schedule](), fridayShows = [Schedule](), saturdayShows = [Schedule](), sundayShows = [Schedule]()
        
        for item in DataStore.sharedInstance.scheduleItems {
            if starredOnly && item.starred == false {
                continue
