title: Select one row in each section of UITableView ios?
body: <p>Scenario: </p>
  
  <p>I have made 2 sections in one UITableView and the user needs to select a row in each section as shown in the screenshot below. </p>
  
  <p>Expected Outcome:
  1. User should be able to select a row in each section </p>
  
  <p>Outcome right now: 
  1. After I have selected row in one section, and then when I select the row in second section, the first selection disappears. </p>
  
  <p>Here is my code: </p>
  
  <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
      // Uncheck the previous checked row
  
      long sec=indexPath.section;
       if(sec==0){
      if(self-&gt;checkedIndexPath)
      {
          UITableViewCell* uncheckCell = [tableView
                                          cellForRowAtIndexPath:self-&gt;checkedIndexPath];
          uncheckCell.accessoryType = UITableViewCellAccessoryNone;
      }
      if([self-&gt;checkedIndexPath isEqual:indexPath])
      {
          self-&gt;checkedIndexPath = nil;
      }
      else
      {
          UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
          cell.accessoryType = UITableViewCellAccessoryCheckmark;
          self-&gt;checkedIndexPath = indexPath;
      }}
  
      if(sec==1){
  
          if(self-&gt;checkedIndexPath)
          {
              UITableViewCell* uncheckCell = [tableView
                                              cellForRowAtIndexPath:self-&gt;checkedIndexPath];
              uncheckCell.accessoryType = UITableViewCellAccessoryNone;
          }
          if([self-&gt;checkedIndexPath isEqual:indexPath])
          {
              self-&gt;checkedIndexPath = nil;
          }
          else
          {
              UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
              cell.accessoryType = UITableViewCellAccessoryCheckmark;
              self-&gt;checkedIndexPath = indexPath;
          }
  
      }
  
  }
  </code></pre>
  
  <p>Help is appreciated. </p>