title: Iterating For In Loop In Swift Using Parse Server
body: <p>I have a chat  filled with users and of course a username array. I want to get the profile picture associated with the username in order for each user in the username array. Parse, however, can only sort by ascending/descending order that I am aware of.</p>
  <p>Therefore, I need to figure out how to sort the data once received.
  I am ultimately appending a url to be used as the pic.</p>
  <pre><code>    func getPics(_ completionHandler: @escaping () -&gt; Void) {
      let query = PFQuery(className: &quot;_User&quot;)
      
      var dictionary: [String : Int] = [:]
      var unit = 0
      for username in usernameArray {
          unit += 1
          dictionary[username] = unit
      }
      query.findObjectsInBackground(block: { (objects: [PFObject]?, error: Error?) in
      if let objects = objects {
          for object in objects {
                  if error == nil {
                      for user in self.usernameArray {
                      let pfuser = object[&quot;username&quot;] as! String
                      if pfuser == user {
                      let imageFile = object[&quot;profilePic&quot;] as? PFFileObject
                      let imageFileString = imageFile?.url as! String
                      if let url = URL(string: imageFileString) {
                          let replacedImageUrlString = imageFileString.replacingOccurrences(of: &quot;[removed for privacy]&quot;, with: &quot;removed for privacy&quot;)
                          let url = replacedImageUrlString as NSString
                          self.urlArray.append(url)
                          }
                                  }
                              }
                          }
          }
                       completionHandler()
                  }
              })
      }
  </code></pre>