 
 	override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
 		// #warning Incomplete implementation, return the number of rows
+		if (self.searchController?.isActive)! && self.searchController?.searchBar.text?.isEmpty == false {
+			return self.filteredItemsArray.count
+		}
+		
 		return self.itemsArray.count
 	}
 
 	override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
 		let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
 		
-		if let item = self.itemsArray[indexPath.row] as? Item {
-			if item.isFolder == true {
-				cell.textLabel?.text = item.name!
-				cell.accessoryType = .disclosureIndicator
-				cell.imageView?.image = UIImage.init(named: "ic_folder_open")
-			} else {
-				cell.textLabel?.text = item.name
+		if (self.searchController?.isActive)! && self.searchController?.searchBar.text?.isEmpty == false {
+			if let item = self.filteredItemsArray[indexPath.row] as? Item {
+				if item.isFolder == true {
+					cell.textLabel?.text = item.name!
+					cell.accessoryType = .disclosureIndicator
+					cell.imageView?.image = UIImage.init(named: "ic_folder_open")
+				} else {
+					cell.textLabel?.text = item.name
+				}
+			}
+		} else {
+			if let item = self.itemsArray[indexPath.row] as? Item {
+				if item.isFolder == true {
+					cell.textLabel?.text = item.name!
+					cell.accessoryType = .disclosureIndicator
+					cell.imageView?.image = UIImage.init(named: "ic_folder_open")
+				} else {
+					cell.textLabel?.text = item.name
+				}
 			}
 		}
 		

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 = "/"

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