2015-01-11 38 views
0

我想添加多個用戶,我一次查詢一個PFRelation。我該如何去做這件事。也將所有的用戶信息存儲在PFRelation中,以便當前用戶可以在以後訪問它?一次添加多個用戶到PFRelation IOS目標c

//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 [email protected]"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; 
} 

回答

0

通過您self.myMatches陣列的項目只是循環,增加每一個到myMatches關係。

一旦完成,只需保存包含關係的父對象,在您的情況下是[PFUser currentUser]

+0

你是什麼意思循環?對於循環或只是一個標準的循環? –

+0

好了,所以用戶已經成功保存解析,但是,當我嘗試從用戶名和objectId中獲取用戶信息之外的任何信息並將其顯示在表視圖中時,它就可以工作。我將發佈上面的代碼。 –

+0

它很好,我發現了錯誤。該錯誤是由於我傳遞一個NSNumber到一個NSString值:P –

相關問題