title: retrieving data from auto id database child
body: <p>I'm kinda new on swift programming, my case is:</p>
  
  <p>I have a database on firebase realtime "see picture", I want to retrieve the <code>firstName</code> and <code>lastName</code> data of a specific ID only.  </p>
  
  <p><a href="https://i.stack.imgur.com/SPpsY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SPpsY.png" alt="enter image description here"></a></p>
  
  <p>for example: 
  When i'm at login screen and logged in using this email: "<strong><code>ali_y_k@hotmail.com</code></strong>", and when going to the next screen i want to display the <code>firstName</code> and <code>lastName</code> of this <code>email</code> in the text fields showing on picture</p>
  
  <p><a href="https://i.stack.imgur.com/8ZuZN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8ZuZN.png" alt="Log in Screen"></a></p>
  
  <p><a href="https://i.stack.imgur.com/tViwH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tViwH.png" alt="HOme Screen"></a></p>
  
  <p>I have tried several solutions but the problem always was I can't enter the random IDs child to fetch the <code>firstName</code> and <code>lastName</code></p>
  
  <p>there is what i tried: 
  <strong>First</strong></p>
  
  <p>func retriveInfo () {</p>
  
  <pre><code>let databaseRef = Database.database().reference().child("User_Informations")
  
  databaseRef.observe(.childAdded) { (snapshot) in
  
      let snapshotValue = snapshot.value as! Dictionary&lt;String,String&gt;
  
      let firstName = snapshotValue["firstName"]!
      let lastName = snapshotValue["lastName"]!
      let email = snapshotValue["email"]!
  
      print(firstName,lastName,email)
  
    }
  }
  </code></pre>
  
  <p>This is printing all data (<code>firstName</code>,<code>lastName</code>,<code>email</code>) from every id</p>
  
  <hr>
  
  <p><strong>Second</strong></p>
  
  <pre><code>func retriveInfo() {
  
      let databaseRef = Database.database().reference().child("User_Informations")
  
  
          databaseRef.observeSingleEvent(of: .value, with: { (snapshot) in
  
              for snap in snapshot.children {
                  let userSnap = snap as! DataSnapshot
                  let uid = userSnap.key //the uid of each user
                  let userDict = userSnap.value as! [String:AnyObject] //child data
                  let firstName = userDict["firstName"] as! String
                  let lastName = userDict["lastName"] as! String
  
                  print("key = \(uid) First Name = \(firstName), Last Name = \(lastName)")
              }
          })
  </code></pre>
  
  <p>This will print every key "Id" and all the info </p>
  
  <p>Thank You in advance :)</p>