Q: Uitableview Accessorytype Checkmark Reset Code I know how to handle with cellaccesory type check mark, here I want a button to Uncheck the entire tablecell which are checkmarked? Here my code, can any one please help me to code
- (void)viewDidAppear:(BOOL)animated
{
UIBarButtonItem *rest = [[UIBarButtonItem alloc]initWithTitle: @"RESET" style:      UIBarButtonItemStyleBordered target: self action: @selector(uncheckCells)];
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
[toolbar setItems:[NSArray arrayWithObjects:rest,flexibleSpace,flexibleSpace,home,nil]];
[self.navigationController.view addSubview:toolbar];
[self.tableView reloadData];
}

Here the code for my functions
-(void)uncheckCells//unchecking function
{
[self.tableView reloadData];//HERE WHAT SHOULD I DO
}
-(void)hom
{
[self dismissModalViewControllerAnimated:YES];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ 
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
 }
cell.textLabel.text = [ar objectAtIndex:indexPath.row];    
cell.selectionStyle=UITableViewCellSelectionStyleNone;
if(cell.accessoryType==UITableViewCellAccessoryCheckmark)
{
cell.backgroundColor=UIColorFromRGB(0xd05818);
cell.detailTextLabel.text=@"packed";
cell.detailTextLabel.textColor=[UIColor cyanColor];
}
else
{
cell.backgroundColor=[UIColor whiteColor];
cell.detailTextLabel.text=@""; 
}
return cell;
[self.tableView reloadData]; 
}
(void) deselect
{   
[self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow]      animated:YES];

}
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath     *)indexPath
{
[tableView reloadData];    
[tableView deselectRowAtIndexPath:indexPath animated:NO];
printf("User selected row %d\n", [indexPath row] + 1);
if ([[tableView cellForRowAtIndexPath:indexPath] accessoryType] ==      UITableViewCellAccessoryCheckmark)
{
[[tableView cellForRowAtIndexPath:indexPath]setAccessoryType:UITableViewCellAccessoryNone];
}
else
    [[tableView cellForRowAtIndexPath:indexPath]setAccessoryType:UITableViewCellAccessoryCheckmark];
    [self performSelector:@selector(deselect) withObject:nil afterDelay:0.0f];
[tableView reloadData];
}


A: If you're doing checkmarks on didSelectRowAtIndexPath: method. A reloadData will work for you.
For eg.
Say you have a button with selector uncheckCells
-(void)uncheckCells
{
   [self.tableView reloadData];
}

This should work you.
EDIT: add cell.accessoryType = UITableViewCellAccessoryNone; in your if (cell == nil) condition.
Or do this:
-(void)uncheckCells
{
for (int section = 0, sectionCount = self.tableView.numberOfSections; section < sectionCount; ++section) {
        for (int row = 0, rowCount = [self.tableView numberOfRowsInSection:section]; row < rowCount; ++row) {
            UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:section]];
            cell.accessoryType = UITableViewCellAccessoryNone;
            cell.accessoryView = nil;
        }
    }
}

I hope it will work.

A: From reading your code, it looks like you are setting the checkmark on the table view itself.
What you should really be doing is storing whether or not a cell has a check mark in your data source, and using this information in the tableView:cellForRowAtIndexPath: method to display a checkmark or not.
And your deselect method should be going through you datasource and unsetting whatever marker you have there that says whether or not your tableview has a check mark.
That way, when you scroll a tableview, or just call [tableView reloadData]; your datastore will be used to decide whether or not to display a checkmark or not.
