title: Adding two of the same values to array instead of one - swift
body: <p>I am trying to make a search bar, where you can search for users names. The cell is showing two things - and image and a label.</p>
  
  <p>The label is showing the users name and the image is showing the profile picture. The image needs the user userID to display his/her picture.</p>
  
  <p>The <code>countryAndCode</code> contains the users userID called country, and the users name called code.</p>
  
  <p>My problem is that it is adding the first user twice and I do not know why or how to change it.</p>
  
  <p>Here is the relevant code, let me know if you would like to see more:</p>
  
  <pre><code>func startObersvingDB() {
          FIRDatabase.database().reference().child("UserInformation").observeEventType(.ChildAdded, withBlock: { snapshot in
  
              let title = snapshot.value!["usersUID"] as? String
              let name = snapshot.value!["userName"] as? String
                  self.tableData.append(title!)
                  self.tableDataNames.append(name!)
  
              for i in 0..&lt;self.tableData.count {
  
                  print(self.tableDataNames.count)
                  print(self.tableData.count)
  
                  self.countryAndCode.append((self.tableData[i], code: self.tableDataNames[i]))//this shows error in XCode some times
                  //if the above code doesn't compile then use the below code
                  print("DONE")
  
                  print(self.countryAndCode)
              }
  
              self.tableView.reloadData() 
          })
      }
  </code></pre>