Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code> - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath { NSMutableSet *selectedUsers = [NSMutableSet set]; static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; PFUser *user; if (self.userResults != nil) { user = [self.userResults objectAtIndex:indexPath.row]; } else { user = [self.allUsers objectAtIndex:indexPath.row]; } cell.textLabel.text = user.username; if ([selectedUsers containsObject:user]) { cell.accessoryType = UITableViewCellAccessoryCheckmark; } else { cell.accessoryType = UITableViewCellAccessoryNone; } return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [self.tableView deselectRowAtIndexPath:indexPath animated:NO]; UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; PFRelation *friendsRelation = [self.currentUser relationforKey:@"friendsRelation"]; PFUser *user = [self.allUsers objectAtIndex:indexPath.row]; [friendsRelation addObject:user]; [self.currentUser saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { if (error) { NSLog(@"Error %@ %@", error, [error userInfo]); } }]; PFUser *user1; if (self.userResults != nil) { user1 = [self.userResults objectAtIndex:indexPath.row]; } else { user1 = [self.allUsers objectAtIndex:indexPath.row]; } if (cell.accessoryType == UITableViewCellAccessoryCheckmark) { cell.accessoryType = UITableViewCellAccessoryNone; [selectedUsers removeObject:user1]; } else { cell.accessoryType = UITableViewCellAccessoryCheckmark; [selectedUsers addObject:user1]; } } </code></pre> <p>See if this helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload