 import UIKit
 import CoreData
 
-class HomeTableViewController: UITableViewController {
+class HomeTableViewController: UITableViewController, UISearchResultsUpdating {
 	// making this an outlet does not work
 	// you have to init and set it to nav bar
 	var moreButton: UIBarButtonItem?
+	var searchController: UISearchController?
 	
 	var userAction = UserAction()
 	var validator = Validator()
 	var uiHelper = UIHelper()
 	var itemsArray = [NSManagedObject]()
+	var filteredItemsArray = [NSManagedObject]()
 	
 	var level = 0
 	var filePath = "/"

		self.navigationItem.rightBarButtonItem = self.moreButton
		
		self.clearsSelectionOnViewWillAppear = true
	}
	
	override func viewWillAppear(_ animated: Bool) {

			}
		}
	}
	
	public func updateSearchResults(for searchController: UISearchController) {
		self.filteredItemsArray = self.itemsArray.filter{items in
			let convertedItems = items as? Item
			
			let convertedItemName = (convertedItems?.name?.lowercased())!
			
			return (convertedItemName.contains(searchController.searchBar.text!.lowercased()))
		}

		
		self.tableView.reloadData()
	}
}
