title: Quickblox - fetch user friends' avatars and display inside a UITableView
body: <p>I need to display entire friend list's avatar images inside UITableView.</p>
  
  <p>I could as well ask this into Quickblox forums but seems like their support is less responsive there.</p>
  
  <p>I have read Quickblox documentation but can't find an efficient way of getting user's avatar images. All I see is <code>[QBContent TDownloadFileWithBlobID]</code>, but I do not know how to use it.</p>
  
  <p>I am fetching contacts using <code>chatContactListDidChange</code> delegate call like below. Now how can I also get all these users' avatar images also?</p>
  
  <p>Note that friendsArray is my data source for the table view, so ideally I would want to store the avatar images as part of the same array.</p>
  
  <pre><code>- (void)chatContactListDidChange:(QBContactList *)contactList
  {
      NSLog(@"contact list changed");
      NSLog(@"current contact list %@", [QBChat instance].contactList);
      [self fetchContacts:[QBChat instance].contactList.contacts];
  }
  
  - (void) fetchContacts : (NSArray *) contactArray
  {
      NSMutableArray * userIDArray = [[NSMutableArray alloc] init];
      for (QBContactListItem * contact in contactArray)
      {
          NSString * userIDString = [NSString stringWithFormat:@"%ld", (unsigned long)contact.userID];
          [userIDArray addObject:userIDString];
      }
  
      if (!userIDArray.count)
      {
          return;
      }
  
      NSString * requestString = [userIDArray componentsJoinedByString:@","];
      [QBUsers usersWithIDs:requestString delegate:self context:@"FetchFriends"];
  }
  
  - (void)completedWithResult:(Result *)result context:(void *)contextInfo
  {
      if([result isKindOfClass:[QBUUserPagedResult class]])
      {
          NSString * context = (__bridge NSString *)contextInfo;
          // Success result
          if(result.success)
          {
              QBUUserPagedResult * pagedResult = (QBUUserPagedResult *)result;
              if ([context isEqualToString:@"FetchFriends"])
              {
                  if (friendsArray)
                  {
                      [friendsArray removeAllObjects];
                  }
                  else
                  {
                      friendsArray = [[NSMutableArray alloc] init];
                  }
  
                  QBUUser * user = [pagedResult.users objectAtIndex:0];
                  //user.blobID   
                  friendsArray addObjectsFromArray:pagedResult.users];
              }            
          }
          else
          {
              NSLog(@"Error getting users: %@", context);
          }
      }
  }
  </code></pre>