I have checked some rows programatically at cellForRowAtIndexPath, and it is showing and working fine. But now I need to fetch the check marked rows. I use the following code:
for (int i=0; i<10; i++) {
NSIndexPath *index = [NSIndexPath indexPathForRow:i inSection:0];
if([motorwayTable cellForRowAtIndexPath:index].accessoryType == UITableViewCellAccessoryCheckmark)
{
NSLog(@"Selected Rows: %d",i);
}
}
And here is my cellForRowAtIndexPath method:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
//cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
cell.textLabel.text = [NSString stringWithFormat:@"arefin %d",[indexPath row]];
if(indexPath.row == 8 || indexPath.row == 7 || indexPath.row == 9)
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
cell.selected = YES;
}
else
{
cell.accessoryType = UITableViewCellAccessoryNone;
}
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
return cell;
}
But the problem is I am getting only visible check marked rows, not getting that are not visible yet. How I can get check marked rows that are not visible yet in UITableView but checked programatically in cellForRowAtIndexPath.
Thanks in Advance!