                         }
                         self.storedShows.append(showObject!)
                         self.storedShows.sort {$0.name < $1.name}
+                        self.shows = self.storedShows
                     }
                     self.tableview.reloadData()
                 })

    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 200
    }
}

    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return shows.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "showCell") as! ShowCell
        cell.showName.text = shows[indexPath.row].name
        cell.showDays.text = shows[indexPath.row].days.joined(separator: ", ")
        cell.nextEpDate.text = shows[indexPath.row].nextEpDate
        switch shows[indexPath.row].status {
        case .Finished: cell.statusView.backgroundColor = #colorLiteral(red: 0.7450980544, green: 0.1568627506, blue: 0.07450980693, alpha: 1)
        case .Running:  cell.statusView.backgroundColor = #colorLiteral(red: 0.2745098174, green: 0.4862745106, blue: 0.1411764771, alpha: 1)
        case .TBD:      cell.statusView.backgroundColor = #colorLiteral(red: 0.7254902124, green: 0.4784313738, blue: 0.09803921729, alpha: 1)
        case .Unknown,.InDev:  cell.statusView.backgroundColor = #colorLiteral(red: 0.501960814, green: 0.501960814, blue: 0.501960814, alpha: 1)
        }
        cell.showImage.downloadImage(from: shows[indexPath.row].imageURL)
        return cell
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let vc = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "showDetails") as! ShowDetailsViewController
        vc.show = shows[indexPath.row]
        searchbar.endEditing(true)
        tableview.deselectRow(at: indexPath, animated: true)
        self.present(vc, animated: false, completion: nil)
    }
