Выберите одну строку в каждом разделе UITableView IOS?

Сценарий:

Я сделал 2 раздела в одном UITableView, и пользователь должен выбрать строку в каждом разделе, как показано на скриншоте ниже.

Ожидаемый результат: 1. Пользователь должен иметь возможность выбрать строку в каждом разделе

Результат прямо сейчас: 1. После того, как я выбрал строку в одном разделе, а затем, когда я выбрал строку во втором разделе, первый выбор исчезает.

Вот мой код:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Uncheck the previous checked row

    long sec=indexPath.section;
     if(sec==0){
    if(self->checkedIndexPath)
    {
        UITableViewCell* uncheckCell = [tableView
                                        cellForRowAtIndexPath:self->checkedIndexPath];
        uncheckCell.accessoryType = UITableViewCellAccessoryNone;
    }
    if([self->checkedIndexPath isEqual:indexPath])
    {
        self->checkedIndexPath = nil;
    }
    else
    {
        UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
        self->checkedIndexPath = indexPath;
    }}

    if(sec==1){

        if(self->checkedIndexPath)
        {
            UITableViewCell* uncheckCell = [tableView
                                            cellForRowAtIndexPath:self->checkedIndexPath];
            uncheckCell.accessoryType = UITableViewCellAccessoryNone;
        }
        if([self->checkedIndexPath isEqual:indexPath])
        {
            self->checkedIndexPath = nil;
        }
        else
        {
            UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
            cell.accessoryType = UITableViewCellAccessoryCheckmark;
            self->checkedIndexPath = indexPath;
        }

    }

}

Помощь приветствуется.

Ответы на вопрос(3)

Ваш ответ на вопрос