【问题标题】:Adding multiple users at once to PFRelation IOS objective c一次将多个用户添加到 PFRelation IOS 目标 c
【发布时间】:2015-03-09 16:50:50
【问题描述】:

我想一次将我查询的多个用户添加到 PFRelation。我该怎么做。还会将所有用户信息存储在 PFRelation 中,以便当前用户以后可以访问它吗?

//so now i am finding users in the PFRelation, but I cannot use the Users information in a table. The code for the table view is at the bottom. 
PFQuery * query =[self.matchesRelation query];
    [query orderByDescending:@"Score"];
    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (!error) {

            self.myMatches =[objects mutableCopy];
            [self.tableView reloadData];




        }

    }];




//code for the tableview, i can set the users username fine but anything else i cant

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

    self.person =[self.myMatches objectAtIndex:indexPath.row];




    cell.name.text = self.person.username;
   //this does not work, why ? 
   cell.score.text =[self.person objectForKey:@"Score"];


    return cell;
}

【问题讨论】:

    标签: objective-c parse-platform cloud pfuser pfrelation


    【解决方案1】:

    只需遍历 self.myMatches 数组中的项目,将每个项目添加到 myMatches 关系中。

    完成后,只需保存包含关系的父对象,在您的情况下为 [PFUser currentUser]

    【讨论】:

    • 你是什么意思循环通过? For in 循环还是只是一个标准的 for 循环?
    • 好的,因此用户已成功保存以进行解析,但是,当我尝试获取除用户名和 objectId 之外的任何用户信息并将其显示在表格视图中时,它不起作用。我会把上面的代码贴出来。
    • 没关系,我发现了错误。该错误是由于我将 NSNumber 传递给 NSString 值:P
    猜你喜欢
    • 2014-04-21
    • 1970-01-01
    • 1970-01-01
    • 2019-02-17
    • 2018-01-08
    • 2017-07-23
    • 1970-01-01
    • 1970-01-01
    • 2013-11-20
    相关资源
    最近更新 更多