i am retrieving data from firebase and i have few buttons to filter the data. this function is working but for see the filtered results i have to exit and reopen the app. here is my code:
self.ItemRef.observe(.value, with: { (snapshot) in
var updatedItem = [MyItem]()
for user_child in (snapshot.children) {
let user_snap = user_child as! DataSnapshot
let dict = user_snap.value as! [String: Any]
guard let category = dict["category"] as? String else { return}
var item = MyItem.init(image1: ItemImage1, image2: "", image3: "",
image4: "", image5: "", name: ItemName,
details: "", size: "", price: price,
gender: "", category: category)
if item.category == filteredCategory {
updatedItem.append(item)
}
}
self.itemList = updatedItem
})