title: How to filter table view cells with a UISegmentedControl in Swift?
body: <p>I've already searched this before asking the question but I didn't find what I need.</p>
  
  <p>I'm building this app where the user puts a task (not going to the app store, just for me and some friends), and the task has a category. For example: school, home, friends, etc. When the user is going to add a new task, there are 2 text fields, the description text field and the category text field. I'm using a UIPickerView so the user picks a category, then, after creating the new task, it will add the category to an array I've created called "categories". </p>
  
  <p>I want to put an UISegmentedControl on top of the table view with the sections:</p>
  
  <p>All - School - Home - Friends</p>
  
  <p>If all is selected, it will show all the cells with no filtering. If not, it will show the cell(s) with the corresponding categories. </p>
  
  <p>I've read that I need to create table view sections to each category, but this would change my code a lot, and I don't even have an idea of how to work with multiple table view sections, I've tried once but it kept repeating the cells of one section in the second.</p>
  
  <p>So how can I filter the cells per category?</p>
  
  <p>Can I just put for example this? :</p>
  
  <pre><code>if //code to check in which section the picker is here {
     if let schoolCell = cell.categories[indexPath.row] == "School" {
          schoolCell.hidden = true
     }
  }
  </code></pre>
  
  <p>Please help me!!!</p>
  
  <p>EDIT:</p>
  
  <p>I have this code by now:</p>
  
  <pre><code>if filterSegmentedControl.selectedSegmentIndex == 1 {
              if categories[indexPath.row] == "School" {
  
              }
      }
  </code></pre>
  
  <p>I just don't know where to go from here. How do I recognize and hide the cells?</p>