Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

GhostDZ9

macrumors regular
Original poster
Sep 13, 2010
118
0
Hey guys so part of my app is a checklist. The table is shown as a group rather then plain.

So basically every time they select a row it puts the accessoryCheckmark at the end of the row and removes the checkmark from everywhere else.

Is there a method or a function that basically works like

Code:
if (indexPath.row isSelected) {
    cell.AccessoryType = UITableViewAccessoryCheckmark;
} else
    cell.AccessoryType = UITableViewAccessoryNone;
 

GhostDZ9

macrumors regular
Original poster
Sep 13, 2010
118
0
Ive actually figured it out, I created an int var and then did this code

Code:
- (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] autorelease];
	}
	
	
	if (indexPath.row == selectedRow){
		cell.accessoryType = UITableViewCellAccessoryCheckmark;
	} else {
		cell.accessoryType  = UITableViewCellAccessoryNone;
	}
	cell.textLabel.text = [rows objectAtIndex:indexPath.row];
	
	return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
	selectedRow = indexPath.row;
	[self.tableView reloadData];


}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.