你如何使用Parse.com搜索UITable

时间:2015-03-18 19:31:19

标签: ios objective-c uitableview parse-platform

我正在处理一个项目,我希望用户能够在UITableView上搜索列表。我添加了搜索栏并将其连接到搜索显示控制器。我不知道如何实际搜索列表并从解析中获取数据,过滤它,将其设置为toUser的PFUser,并显示它。有人知道怎么做吗?

这是我保存邮件的代码:

 if (toUser!= nil){
       app[@"toUser"]=toUser;



    }
        [app save];

以下是表格视图的一些代码段:

这会显示用户并过滤掉当前用户:

 ParseExampleAppDelegate *delegate=[[UIApplication sharedApplication] delegate];
    PFQuery *query = [PFUser query];
    users = [[query findObjects] mutableCopy];
    for(PFUser *user in users){
        if ([user.objectId isEqualToString:delegate.applicationUser.objectId]){
            [users removeObject:user];
            break;
        }


    }

    [users removeObject:delegate.applicationUser];
    NSLog(@"all user: %lu",users.count);
    [self.usersTable setDelegate:self];
    [self.usersTable setDataSource:self];
    [self.usersTable reloadData];

        [self.usersTable reloadData];

表格视图的一些方法:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"userCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    PFObject *tempObject = [users objectAtIndex:indexPath.row];

    cell.text= [tempObject objectForKey:@"username"];

    return cell;

    NSMutableArray *filteredStrings;
    BOOL isFiltered;

}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    NSLog(@"users:%lu",[users count]);
    return [users count];
}

感谢您的帮助,

armanb21

0 个答案:

没有答案