title: Retrieving data with Firebase database in iOS
body: <p>In my app I have a simple user base that looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/sF2qW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sF2qW.png" alt="enter image description here"></a></p>
  
  <p>What I'm trying to do is to simply fetch this list once, to check wether a username is valid when a new user signs up with a new username.<br>
  The thing is that the only ways I found to retrieve data utilize some sort of observer methods, which are not good for me. </p>
  
  <p>The logic I'm trying to achieve (with the retrieving method that doesn't work) :</p>
  
  <pre><code>// When user tries to sign up with a new username
  
  let username = nicknameField.text?.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())    
  
  self.usersRef.observeEventType(.Value) { (snapshot: FIRDataSnapshot) in
      let dict = snapshot.value as! NSDictionary
      for val in dict.allValues {
          if username == val as! String {
              // Present alert
              return
          }
      }
  }   
  
  self.usersRef.child(username).setValue(username) { (error, dbRef) in
      if error == nil {
          // Continue
      }
  }
  </code></pre>
  
  <p>How can I simply just fetch the list of users once?
  Thanks in advance!</p>