 			}
 		}
 	}
+	
+	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()
+	}
 }

import UIKit
import CoreData

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

		self.navigationItem.rightBarButtonItem = self.moreButton
		
		self.clearsSelectionOnViewWillAppear = true
		
		self.searchController = UISearchController.init(searchResultsController: nil)
		self.searchController?.searchResultsUpdater = self
		self.searchController?.dimsBackgroundDuringPresentation = false
		self.searchController?.definesPresentationContext = true
		self.tableView.tableHeaderView = self.searchController?.searchBar
	}
	
	override func viewWillAppear(_ animated: Bool) {
