I am implementing filters in a UITableView through checkmarks for different title headings .
According to selected cells,a query runs on local database and i get a result.I am saving filter result in an array and pass this array through push segue into another uitableviewview and display the result.
I am using modal segue to go on the filter screen.
But the problem is that when i get back to filter screen, my selected filters which are checkmarked cells disappears.
Here is my code to select rows:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
long sec = [indexPath section];
if(sec==0){
if(cell.accessoryType == UITableViewCellAccessoryNone) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
[sportsSelectedRows addObject:indexPath];
}
else {
cell.accessoryType = UITableViewCellAccessoryNone;
[sportsSelectedRows removeObject:indexPath];
}
}
else if(sec==1){
if(cell.accessoryType == UITableViewCellAccessoryNone) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
[areaSelectedRows addObject:indexPath];
}
else {
cell.accessoryType = UITableViewCellAccessoryNone;
[areaSelectedRows removeObject:indexPath];}
}
else if(sec==2){
cell.tag = indexPath.section;
for (UITableViewCell *cell in [tableView visibleCells]) {
if (cell.accessoryType != UITableViewCellAccessoryNone && cell.tag == indexPath.section) {
cell.accessoryType = UITableViewCellAccessoryNone;
}
}
if(cell.accessoryType == UITableViewCellAccessoryNone) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
[daySelectedRows removeAllObjects];
[daySelectedRows addObject:indexPath];
}
else {
cell.accessoryType = UITableViewCellAccessoryNone;
[daySelectedRows removeObject:indexPath];}
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
Could you help in solving this.