i wanna do a single selection in my table view here is my code any help would be appreciated thanks
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Selection logic will go here to place a tick mark next to the selected country
currentCategory = [[NSMutableArray alloc] init];
[tableView deselectRowAtIndexPath:indexPath animated:NO];
NSInteger catIndex = [countryList indexOfObject:self.currentCategory];
if (catIndex == indexPath.row) {
return;
}
NSIndexPath *oldIndexPath = [NSIndexPath indexPathForRow:catIndex inSection:0];
UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
if (newCell.accessoryType == UITableViewCellAccessoryNone) {
newCell.accessoryType = UITableViewCellAccessoryCheckmark;
self.currentCategory = [countryList objectAtIndex:indexPath.row];
}
UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:oldIndexPath];
if (oldCell.accessoryType == UITableViewCellAccessoryCheckmark) {
oldCell.accessoryType = UITableViewCellAccessoryNone;
}
NSLog(@"the selected cell is %@",newCell);
}
current category is a string not a array here is the correct code for it
{
}