     let reuseIdentifierCell = "BillCell"
     let reuseIdentifierHeader = "BillHeader"
     
+    @IBOutlet weak var searchBar: UISearchBar!
+    
+    
     var managedObjectContext: NSManagedObjectContext? = nil
     var billSegue: Bill? = nil
     
     //Data
-    var data: [SubCategory] = []
+    var data: [SubCategory] = [] {
+        didSet {
+            self.collectionView.reloadData()
+        }
+    }
     
     override func viewDidLoad() {
         super.viewDidLoad()

                })
            }
        }
    }
}
        return UIEdgeInsetsMake(10, 5, 10, 5); //top,left,bottom,right
    }
    
    //MARK: - Search control
    
    func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {
        print(#function)
        autoreleasepool {
            var predicate: NSPredicate? = nil
            var error: NSError? = nil
            var result: [AnyObject]?
            
            if self.searchBar.text?.characters.count != 0 {
                predicate = NSPredicate(format: "(name contains [cd] %@)", searchBar.text!)
            }
            
            
            
            let fetch: NSFetchRequest = NSFetchRequest(entityName: "SubCategory")
            fetch.predicate = predicate
            do {
                result = try self.managedObjectContext!.executeFetchRequest(fetch)
            } catch let nserror1 as NSError{
