Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- addedByUser: "user"
- noText: "NO"
- question: "Hello World?"
- yesCount: 0
- yesText: "YES"
- @IBAction func askTapped(_ sender: Any) {
- //post under childByAutoID
- let post = Post(question: daquestion, addedByUser: UserDefaults.standard.object(forKey: "name") as! String, yesText: dayes, noText: dano, yesCount: 0)
- let postRef = dbRef.childByAutoId()
- let postKey = postRef.key
- var autoIDs = [""]
- autoIDs.insert(postKey, at: 0)
- print (" child id(postKey)")
- postRef.setValue(post.toAnyObject())
- previousVC.tableView.reloadData()
- navigationController?.popViewController(animated: true)
- }
- @IBAction func yesTapped(_ sender: UIButton) {
- self.Yescount = Yescount + 1
- dbRef.child("autoID").child("yesCount").setValue(Yescount)
- let childCount = dbRef.child("autoID").value(forKey: "yesCount") as! Int
- sender.setTitle("(String(describing: childCount))", for: [])
- dbRef.observe(.childChanged, with: { snapshot in
- })
- }
Add Comment
Please, Sign In to add comment