title: Expanding & Collapsing 1 Tableview Section with 1 row
body: <p>My tableview consist of 2 sections. I want to expand and collapse only 1 section. Currently I can collapse it but am getting errors when trying to expand it.   </p>
  
  <p>I would post an image to show the UI but the new question interface is super confusing on how to embed an image from your pc into the question. You used to be able to easily drag an image into the question. </p>
  
  <pre><code>var section1 = ExpandableCell(isExpanded: true, section: ["Section 1"])
  
  @objc func handleExpandClose(button: UIButton) {
      let indexPath = IndexPath(row: 0, section: 0)
  
      let isExpanded = section1.isExpanded
      section1.isExpanded = !isExpanded
      if isExpanded {
          section1.section.removeAll()
          tableView.deleteRows(at: [indexPath], with: .fade)
  
      } else {
          tableView.insertRows(at: [indexPath], with: .fade)
      }
  }
  
  
   func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -&gt; UIView? {
      let button = UIButton(type: .system)
      button.addTarget(self, action: #selector(handleExpandClose), for: .touchUpInside)
      return button
  }
  
  func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      if section == 0 {
          return section1.section.count
      }
  
      return 1
  }
  </code></pre>