I’m taking the data from the database, the data comes down correctly.
services
-Ghkgkkjgkjg
category: "veterinarian"
name: "Ghkhkjhkjh"
-Jljlkjlkj
category: "veterinarian"
name: "HJHGJH"
-KJkjhkjhkj
category: "trainer"
name: "hkjhkjhkjhh"
Now I would like to create another tableView with only the categories, in this example I would like 2 rows to appear in the tableView:
veterinarian
trainer
Then the user taps for example on “veterinarian” and will load another tableView with only the veterinarians, this is my code and I can’t see just the category rows.
struct ServiceModelRead {
var idService: String?
var category: String?
var name: String?
}
var serviceArray = [ServiceModelRead]()
self.serviceArray.removeAll()
let rootRef = Database.database().reference()
let ref = rootRef.child(RefDatabase.services.rawValue)
ref.observe(.value, with: { snapshot in
if let todoDict = snapshot.value as? [String : AnyObject] {
for (_,todoElement) in todoDict {
print(todoElement);
var serviceModel = ServiceModelRead()
serviceModel.category = todoElement[RefDatabase.category.rawValue]?.stringValue
self.serviceArray.append(serviceModel)
}
}
self.tableView.reloadData()
}) { (error) in
print(error.localizedDescription)
}
Recognized by Google Cloud Collective
1