Full selection and multiple selection functions of UITableView
The multiple choice method is as follows:
-(Void) tableView :( UITableView *) tableViewdidSelectRowAtIndexPath :( NSIndexPath *) indexPath
{
[TableViewdeselectRowAtIndexPath: indexPath animated: YES];
Custom * cell = (Custom *) [tableView cellForRowAtIndexPath: indexPath];
NSUIntegerrow = [indexPath row];
NSMutableDictionary * dic = [contacts objectAtIndex: row];
If ([[dicobjectForKey: @ "checked"] isdesktostring: @ "NO"]) {
[Dic setObject: @ "YES" forKey: @ "checked"];
[Cell setChecked: YES];
} Else {
[Dic setObject: @ "NO" forKey: @ "checked"];
[Cell setChecked: NO];
}
}
Add the BOOL attribute checked and the setting method setChecked in the cell class...
Select all methods as follows:
NSArray * anArrayOfIndexPath = [NSArray arrayWithArray: [contactListindexPathsForVisibleRows];
For (int I = 0; I <[contacts count]; I ++ ){
NSIndexPath * indexPath = [anArrayOfIndexPath objectAtIndex: I];
Custom * cell = (Custom *) [contactListcellForRowAtIndexPath: indexPath];
NSUInteger row = [indexPath row];
NSMutableDictionary * dic = [contacts objectAtIndex: row];
If ([[[(UIButton *) sender titleLabel] text] isw.tostring: @ "select all"]) {
[Dic setObject: @ "YES" forKey: @ "checked"];
[Cell setChecked: YES];
} Else {
[Dic setObject: @ "NO" forKey: @ "checked"];
[Cell setChecked: NO];
}
}