2

This page http://networkpx.blogspot.com/2009/07/multiple-row-selection-with-uitableview.html

mentions a way to implement table views that can allow multiple selections of rows.

At the time of this article, it seems that it was not a blessed way of doing this.

Now, apparently, Apple is allowing this kind of tableViews.

The article mentions this

NSArray* selectedRows = [tableView indexPathsForSelectedRows];

as a way of getting a list of all rows selected but this is not a legal functionality of the SDK.

The big question is: how do I get a list of all rows selected, so I can perform an action with them?

thanks

EDIT

To answer some questions... this is the code I am using to discover if a row is selected, but this is giving me zero entries.

NSMutableArray *selectedRows = [[NSMutableArray alloc] init];

for (int i=0; i<[list count]; i++) {

 NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
 UITableViewCell *aCell = (UITableViewCell*) [myTable cellForRowAtIndexPath:indexPath];
 if (aCell.accessoryType == UITableViewCellAccessoryCheckmark) {
  [selectedRows addObject:indexPath];
 }
}

// selectedRows has always 0 entries... all cells give me their type as UITableViewCellAccessoryNone even those with checkmark
Roger
  • 243
  • 2
  • 4
  • 14
  • Where are you using this code? – KingofBliss Dec 13 '10 at 17:20
  • in a class where the tableview is implemented. All cells are returned as UITableViewCellAccessoryNone – Roger Dec 13 '10 at 17:25
  • possible duplicate of [How can I select multiple rows in UITableView](http://stackoverflow.com/questions/1818017/how-can-i-select-multiple-rows-in-uitableview) – Bo Persson Jul 06 '12 at 18:16
  • [Here](https://github.com/vikingosegundo/my-programming-examples/tree/master/VSCheckFavorites) I posted a sample code, that allows to check cells – vikingosegundo Dec 13 '10 at 16:32
  • You should take a look at: https://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/TableView_iPhone/ManageSelections/ManageSelections.html%23//apple_ref/doc/uid/TP40007451-CH9-SW10 and: http://stackoverflow.com/questions/308081/is-it-possible-to-configure-a-uitableview-to-allow-multiple-selection -marc – henklein Dec 13 '10 at 16:16

3 Answers3

2

Apple will reject your app for for iOS 4 and below.

We found the following non-public API/s in your app:

indexPathsForSelectedRows

lxcid
  • 1,023
  • 1
  • 11
  • 18
1

Create a NSMutableArray. Whenever a table cell is selected insert the current indexpath in the array. whenever he deselects the cell remove it from the array. Final array will have everything you selected.

MultipleCheck in Table – UITableView Example with Demo

http://sugartin.info/2011/08/19/multiplecheck-in-table-uitableview/

suspectus
  • 16,548
  • 8
  • 49
  • 57
ipraba
  • 16,485
  • 4
  • 59
  • 58
0

Are you looking to have the user select multiple rows at the same time? If not you could create an array that holds each row that is selected as the user selects them.

Also for the check mark you could just subclass UITableViewCell.

How to subClass UITableViewCell and use it to not clear UILabel background color on UITabeViewCell selected?

Community
  • 1
  • 1
Oscar
  • 1,025
  • 2
  • 15
  • 25