title: finding a tableView cells superView
body: <p>I am trying to create a range slider that has labels representing the sliders handle value. I have the slider enabled but when I try to add the labels to the sliders subview, my app crashes with the error</p>
  <blockquote>
  <p>Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value</p>
  </blockquote>
  <p>The slider is inside of a tableViewCell and I am initializing this cell inside of the tableView VC with the code below,</p>
  <pre><code>if indexPath.section == 2 {
          let costRangeCell = AgeRangeCell(style: .default, reuseIdentifier: nil)
  
          let contentView = costRangeCell.rangeSlider.superview! 
  </code></pre>
  <p>// my declaration of contentView is where my app is crashing.</p>
  <pre><code>        costRangeCell.rangeSlider.minimumValue = 0
          costRangeCell.rangeSlider.maximumValue = 100
          costRangeCell.rangeSlider.lowValue = 0
          costRangeCell.rangeSlider.highValue = 100
          costRangeCell.rangeSlider.minimumDistance = 20
  
          let lowLabel = UILabel()
          contentView.addSubview(lowLabel)
          lowLabel.textAlignment = .center
          lowLabel.frame = CGRect(x:0, y:0, width: 60, height: 20)
  
          let highLabel = UILabel()
          contentView.addSubview(highLabel)
          highLabel.textAlignment = .center
          highLabel.frame = CGRect(x: 0, y: 0, width: 60, height: 20)
  
          costRangeCell.rangeSlider.valuesChangedHandler = { [weak self] in
            
          let lowCenterInSlider = CGPoint(x:costRangeCell.rangeSlider.lowCenter.x, y: costRangeCell.rangeSlider.lowCenter.y - 30)
          let highCenterInSlider = CGPoint(x:costRangeCell.rangeSlider.highCenter.x, y: costRangeCell.rangeSlider.highCenter.y - 30)
          let lowCenterInView = costRangeCell.rangeSlider.convert(lowCenterInSlider, to: contentView)
          let highCenterInView = costRangeCell.rangeSlider.convert(highCenterInSlider, to: contentView)
  
          lowLabel.center = lowCenterInView
          highLabel.center = highCenterInView
          lowLabel.text = String(format: &quot;%.1f&quot;, costRangeCell.rangeSlider.lowValue)
          highLabel.text = String(format: &quot;%.1f&quot;, costRangeCell.rangeSlider.highValue)
          }
          
          costRangeCell.rangeSlider.addTarget(self, action: #selector(handleMinAgeChange), for: .valueChanged)
          let minAge = user?.minSeekingCost ?? SettingsViewController.defaultMinSeekingCost
          costRangeCell.rangeLabel.text = &quot; $\(minAge)&quot;
          return costRangeCell
      }
  </code></pre>
  <p>Is there a different way for me to gain access to the cells range slider superView?</p>
  <p>ageRange class,</p>
  <pre><code>class AgeRangeCell: UITableViewCell {
  
  let rangeSlider: AORangeSlider = {
      let slider = AORangeSlider()
      slider.minimumValue = 20
      slider.maximumValue = 200
      return slider
  }()
  
  
  let rangeLabel: UILabel = {
      let label = costRangeLabel()
      label.text = &quot;$ &quot;
      return label
  }()
  
  
  
  
  class costRangeLabel: UILabel {
      override var intrinsicContentSize: CGSize {
          return .init(width: 80, height: 50)
      }
  }
  
  override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
      super.init(style: style, reuseIdentifier: reuseIdentifier)
      
      contentView.isUserInteractionEnabled = true
  
      let overallStackView = UIStackView(arrangedSubviews: [
          UIStackView(arrangedSubviews: [rangeLabel, rangeLabel]),
          ])
      overallStackView.axis = .horizontal
      overallStackView.spacing = 16
      addSubview(overallStackView)
      overallStackView.anchor(top: topAnchor, leading: leadingAnchor, bottom: bottomAnchor, trailing: trailingAnchor, padding: .init(top: 16, left: 16, bottom: 16, right: 16))
      
  }
  
  required init?(coder aDecoder: NSCoder) {
      fatalError(&quot;init(coder:) has not been implemented&quot;)
  }
  
    }
  </code></pre>
  <p>AORangeSlider is a custom Slider.</p>