How can you get the selected rows from a UITableView?
ios, objective-c, uitableview, xcode
Solution
For the `indexPathsForSelectedRows:` method to work properly, you have to configure the table view to allow multiple selection of cells:
tableView.allowsMultipleSelection = YES;
Problem
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?