Hi,
I would like to be able to take two fields of a firestorm document and then set two UILabels to those fields. Here is my code:
Thanks in advance!
I would like to be able to take two fields of a firestorm document and then set two UILabels to those fields. Here is my code:
Code Block import UIKit import SafariServices import WebKit import Firebase class TheRiddle: UIViewController { @IBOutlet weak var leading_TheRiddle: NSLayoutConstraint! @IBOutlet weak var trailing_TheRiddle: NSLayoutConstraint! @IBOutlet weak var CurrentRiddle: UILabel! @IBOutlet weak var PreviousRiddle: UILabel! var menuOut = false override func viewDidLoad() { super.viewDidLoad() let db = Firestore.firestore() db.collection("TheRiddle").document("Riddles").getDocument { (document, error) in //check for error if error == nil { //check if document exists if document != nil { }else { if let currentRiddle = document!.get("CurrentRiddle") as? String { self.CurrentRiddle.text = "This Weeks Riddle: " + currentRiddle } if let previousRiddle = document!.get("CurrentRiddle") as? String { self.CurrentRiddle.text = "Previous Riddle: " + previousRiddle } } } } } @IBAction func RiddleAnswerForm(_ sender: Any) { let vc = SFSafariViewController(url: URL(string: "https://forms.office.com/Pages/ResponsePage.aspx?id=ytAqTDte6UK-KD5v_kOm4Y843IzqmYtFlDtLrfRYsi1UMFpUMk1GN01GS05BVFlJUElONk4yR1hKUCQlQCN0PWcu")!) present(vc, animated: true) } @IBAction func menuTappedTheRiddle(_ sender: Any) { if menuOut == false { leading_TheRiddle.constant = 150 trailing_TheRiddle.constant = -150 menuOut = true } else { leading_TheRiddle.constant = 0 trailing_TheRiddle.constant = 0 menuOut = false } UIView.animate(withDuration: 0.2, delay: 0.0, options: .curveEaseIn, animations: { self.view.layoutIfNeeded() }) { (animationComplete) in print("The animation is complete") } } }
Thanks in advance!
Didn't you read my replies?”!=“ is not, right? Thats what I have learned.
Your code (updated one):
Code Block if snapshot != nil { //# Doing nothing when `snapshot` is *not nil* }else { //# This code block is executed when `snapshot` *is nil* //... }
is equivalent to:
Code Block if snapshot == nil { //# This code block is executed when `snapshot` *is nil* //... }
You may need to learn how if-else works,