显示用户列表,登录用户除外,quickblox ios

时间:2014-07-03 07:11:00

标签: ios quickblox

我在ios中编写了一个代码,我正在使用quickblox api进行ios视频​​聊天: -

这是我的代码: -

//获取用户结果

- (void)completedWithResult:(Result *)result{ 

AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
if(result.success && [result isKindOfClass:[QBUUserPagedResult class]]){

    QBUUserPagedResult *usersResult = (QBUUserPagedResult *)result;
    NSLog(@"Users=%@", usersResult.users);
    NSLog(@"Page parameters: currentPage %lu, totalPages %lu, perPage %lu, totalEntries %lu",
       (unsigned long)usersResult.currentPage,
       (unsigned long)usersResult.totalPages,
       (unsigned long)usersResult.perPage,
       (unsigned long)usersResult.totalEntries);
    [noOfuser removeAllObjects];
    [noOfuser addObjectsFromArray:usersResult.users];

    for (int i=0; i<[noOfuser count];i++)
    {
        QBUUser *tmpUser=(QBUUser *)[noOfuser objectAtIndex:i];
        NSLog(@"bbbbb%@",tmpUser);
        if (appDelegate.currentUser==i) {
            [noOfuser removeObject:noOfuser[i]];
        }
    }
    [self.tblTeamList reloadData];
}else{
    NSLog(@"errors=%@", result.errors);} }

这里我要获取添加到我的Quickblox应用程序中的用户列表,但我不想显示列表中登录的人员的姓名,我想只显示除了登录用户。你能否检查一下代码并纠正我的错误。

实施例: -

如果我在一个组中有四个名为a,b,c,d的用户,那么当a登录时,b,c,d应显示为a。

1 个答案:

答案 0 :(得分:0)

QBUUser *currentUser = ...

...

if(result.success && [result isKindOfClass:[QBUUserPagedResult class]]){
     QBUUserPagedResult *usersResult = (QBUUserPagedResult *)result;

     NSMutableArray *allUsers = [NSMutableArray arrayWithArray:usersResult.users];

     NSMutableArray *allUsersCopy = [NSMutableArray arrayWithArray:allUsers];
     for(QBUUser *user in allUsersCopy){
         if(user.ID == currentUser.ID){
             [allUsers removeObject:user];
             break;
         }
     }

}

下一步 - 使用 allUsers 数组 - 它不包含您当前的用户