title: Detect Change in UISegmentedControl inside UITableView HeaderView
body: <p>I am trying to control my <code>UITableView</code> based on the <code>selectedSegmentIndex</code> of a <code>UISegmentedControl</code> inside my UITableView header. Essentially, I want this <code>UISegmentedControl</code> to work like Twitter's 'Me' tab. I have the <code>UISegmentedControl</code> inside a <code>UITableView</code> header and it is dequeued using this method:</p>
  
  <pre><code>override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -&gt; UIView? {
      let cell = tableView.dequeueReusableCell(withIdentifier: "sectionDetailsHeaderView") as! SectionDetailsHeaderTableViewCell
      return cell
  }
  </code></pre>
  
  <p>I have an outlet for the UISegmentedControl hooked up to <code>SectionDetailsHeaderTableViewCell</code>, but I can't figure out how to detect a change in the UISegmentedControl. I want to set a variable, <code>var segmentedControlValue = Int()</code> to the <code>selectedSegmentIndex</code> every time the value changes and call a function, <code>func chooseDataToDisplay() {}</code> when the value changes. How do I go about doing this?</p>