title: Animating a Double from 0 to 1 in Swift over a specified interval
body: <p>I am trying to call a function continually over a specified period of time by passing through the progress indicator (Double) should change from 0 to 1 over that period of time. Is there a way to "animate" such change from 0 to 1 in Swift?</p>
  
  <p>UPDATE:</p>
  
  <p>Here is my code for updating the data for a pie chart based on <a href="https://github.com/danielgindi/ios-charts" rel="nofollow">https://github.com/danielgindi/ios-charts</a></p>
  
  <pre><code>internal func animateDataChange(fromDataSet: PieChartDataSet, toDataSet: PieChartDataSet, progress: Double) -&gt; PieChartDataSet {
      var dataEntries: [ChartDataEntry] = []
      for i in 0..&lt;fromDataSet.yVals.count {
          let yValue = (toDataSet.yVals[i].value - fromDataSet.yVals[i].value) * progress + fromDataSet.yVals[i].value
          let dataEntry = ChartDataEntry(value: yValue, xIndex: i)
          dataEntries.append(dataEntry)
      }
      let animatedDataSet = PieChartDataSet(yVals: dataEntries, label: "")
      return animatedDataSet
  }
  </code></pre>
  
  <p>What I'm trying to do is to animate the change between the two data sets and the progress of the change is reflected in the "progress" parameter. I need to keep calling the function until "progress" = 1.</p>