Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. var testTable = ["active ingredient", "titanium dioxide 3.1 %other ingredients", "aqua", "water", "cyclopentasiloxane", "cyclohexasiloxane dimethicone", "vinyl dimethicone crosspolymer", "methyl trimethicone", "peg-10 dimethicone", "alcohol", "dimethicone"]
  2.  
  3. func loadData(){
  4. for i in 0..<testTable.count {
  5.  
  6. let db = Firestore.firestore()
  7.  
  8. db.collection("Ingredients").whereField("compName", arrayContains: testTable[i] ).getDocuments(){
  9. querySnapshot, error in
  10. if let error = error {
  11. print("(error.localizedDescription)")
  12. }else if let querySnapshot = querySnapshot {
  13. if (querySnapshot.isEmpty == false){
  14.  
  15. let res = querySnapshot.documents.compactMap({Ingredients(dictionary: $0.data())})
  16. self.ingredientsArray.append(contentsOf:res)
  17. print(self.testTable[i])
  18. DispatchQueue.main.async {
  19. self.tableView.reloadData()
  20.  
  21. }
  22. }
  23. }
  24.  
  25. }
  26.  
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement