Reputation: 2851
So I've written this code to put a checkmark beside a row that I want selected because I want multiple selected rows
UITableViewCell *cell = [tableView cellForRowAtIndexPath:path];
if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
cell.accessoryType = UITableViewCellAccessoryNone;
} else {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
but when I use the method:
NSArray *selectedIndexPaths = [self.LightsView indexPathsForSelectedRows];
it only gets the last row that I clicked on. Is the checkmark not selecting it?
Upvotes: 15
Views: 21184
Reputation: 7845
For the indexPathsForSelectedRows:
method to work properly, you have to configure the table view to allow multiple selection of cells:
tableView.allowsMultipleSelection = YES;
Upvotes: 23