title: How to know which section is selected ? Swift
body: <p>I’m working on a <em>dynamic</em> <code>tableView</code> with a lot of items, divided into <em>sections</em>, based on their selection. The <em>sections</em> are the client names, the items (i.e. the <code>rows</code> in each <em>section</em>) are the foods selected by the client. So far I'm having some issues about how to update it.<br/>I used a table with 4 buttons (C1,C2,C3,C4).
   Then when a client is selected i append it in an empty array (client) that i use for the header section.
   <br/>I've also created 4 empty <em>arrays</em> for each <em>section</em> (<code>myarray</code>,<code>c2array</code>,<code>c3array</code>,<code>c4array</code>) that I fill with the item selected by the client but there's a confusion in a part of my <em>code</em>.</p>
  
  <p>In order to fill the <code>cell</code> for each <code>row</code> I wrote this:</p>
  
  <pre><code>    let cell = tableView.dequeueReusableCell(withIdentifier: "Leschoix", for:indexPath) as UITableViewCell!
  
      if indexPath.section == 0 {
          cell?.textLabel?.text = myarray[indexPath.row]
          }
  
      if indexPath.section == 1  {
          cell?.textLabel?.text = c2array[indexPath.row]
      }
  
      if indexPath.section == 2 {
          cell?.textLabel?.text = c3array[indexPath.row]
      }
  
      if indexPath.section == 3 {
          cell?.textLabel?.text = c4array[indexPath.row]
      }
  
          }
  </code></pre>
  
  <p>After running a quick simulation it I get this</p>
  
  <hr>
  
  <ol>
  <li>C1: meal A meal B  (I select C1 and chooses 2 meals A and B)</li>
  </ol>
  
  <hr>
  
  <ol start="2">
  <li>C2: meal C meal D </li>
  </ol>
  
  <p>Now when I try to add a meal E to C1 again (I select C1 button) I get:</p>
  
  <hr>
  
  <ol start="2">
  <li>C2: meal C meal D meal E instead of updating C1</li>
  </ol>
  
  <p>So my <em>code</em> is saying if there's 1 <em>section</em> fill the <em>array</em> with the text, if there are 2 <em>section</em>, fill it with <code>c2array</code>, and so on..and in this case we have 2 <em>sections</em> so it won't update the 1st one. which means I can't update the first section. How can I say <strong>If you're in the <em>section</em> i then update the appropriate array</strong>?.  I'm looking for a way to say that whenever client i is selected then i'm in <em>section</em> j and fill/update the corresponding array accordingly. Thank you for your help!</p>