title: Improve perfomance when scrolling UITableView with custom cells
body: <p>I have a <code>UITableView</code> which cells are custom, and cell has a view with chart (<code>Charts</code> library). Data for chart is pretty big (it stored as a property of Controller), it appears during few seconds. </p>
  
  <p>Also I do some Chart's View setup (only little UI changes) in <code>setSelected</code> method in custom <code>TableViewCell</code> class</p>
  
  <p>When scrolling table view there some lags appear. I suppose it happens because of heavy content I want to display.</p>
  
  <p>During solving this problem I've thought about four solutions:</p>
  
  <ol>
  <li><p>Load all cells in <code>ViewDidAppear</code>, save them to array, in <code>CellForRowAt</code> method show cells from this array.</p></li>
  <li><p>Put table view into scroll view, make content's height pretty big to fit all cells in table view.</p></li>
  <li><p>Make chart loads only after cell's loading and its content view appearing. Show activity indicator while chart's loading is on.</p></li>
  <li><p>Put chart's loading in background thread.</p></li>
  </ol>
  
  <p>First two approaches seem to me a not so good in terms of memory managment. But I am not sure, maybe there is common solution which I have not known.</p>
  
  <p>Some code example from project:</p>
  
  <pre><code>     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
  
      let graphCell = tableView.dequeueReusableCell(withIdentifier: Cells.graphViewCell) as! GraphViewCell
  
      graphCell.lineChartView.data = track.chartDataForHeight()
      return graphCell
  }
  </code></pre>
  
  <p>Here's <code>track</code> is variable where I store data for chart.</p>