Guest User

Untitled

a guest
Jan 17th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. addedByUser: "user"
  2.  
  3. noText: "NO"
  4.  
  5. question: "Hello World?"
  6.  
  7. yesCount: 0
  8.  
  9. yesText: "YES"
  10.  
  11. @IBAction func askTapped(_ sender: Any) {
  12. //post under childByAutoID
  13. let post = Post(question: daquestion, addedByUser: UserDefaults.standard.object(forKey: "name") as! String, yesText: dayes, noText: dano, yesCount: 0)
  14.  
  15. let postRef = dbRef.childByAutoId()
  16. let postKey = postRef.key
  17. var autoIDs = [""]
  18. autoIDs.insert(postKey, at: 0)
  19.  
  20. print (" child id(postKey)")
  21.  
  22. postRef.setValue(post.toAnyObject())
  23.  
  24. previousVC.tableView.reloadData()
  25.  
  26. navigationController?.popViewController(animated: true)
  27.  
  28. }
  29.  
  30. @IBAction func yesTapped(_ sender: UIButton) {
  31. self.Yescount = Yescount + 1
  32. dbRef.child("autoID").child("yesCount").setValue(Yescount)
  33. let childCount = dbRef.child("autoID").value(forKey: "yesCount") as! Int
  34.  
  35. sender.setTitle("(String(describing: childCount))", for: [])
  36.  
  37. dbRef.observe(.childChanged, with: { snapshot in
  38.  
  39. })
  40.  
  41. }
Add Comment
Please, Sign In to add comment