Multi Select TableView

Published on Thursday, 13 August 2015

Want to select more than one row in a TableView?

[gist 1e4aefb923ee02c652fd /]

TableViewController.m

NSArray *selectedRows = [self.tableView indexPathsForSelectedRows];
NSLog(@"selected: %@", selectedRows);
for (NSIndexPath *indexPath in selectedRows) {
    if(indexPath.section == 0){
        Player *player = [self.playersNotInGame objectAtIndex:indexPath.row];
        NSLog(@"1: %@", player.PlayerName);
    }
    else if(indexPath.section == 1){
        Player *player = [self.playersInGame objectAtIndex:indexPath.row];
        NSLog(@"2: %@", player.PlayerName);
    }
}

TVC.m

self.tableView.allowsMultipleSelection = YES;

Wordpress Original Link