0

I'm getting info from a GPS service giving an array of addresses, each one containing a duration of time in seconds. So from point A to Point B the time duration is 250 seconds and from Point B to C 100 seconds. It does not add the times together to make a complete route time, I have to do that on my own. In above example I would want to see 250 on the first row and 350 on the 2nd row etc. So I am calculating the values together to get the true total for each address by adding them from row to row right inside my table. I grab each address's value from the route's array based on my table index.path row. I populate that into a table and it works beautifuly as so:

let secondsToAdd = Int(self.thisRoute.ttaForSubleg(UInt(indexPath.row)).duration)

duration += secondsToAdd

However when table is scrolled up and down and cells are dequeued and re-queued values are getting added to again and again. I need to reset the duration somewhere to 0 as so:

duration = 0

but I'm stumped as to where!

Chaim Friedman
  • 720
  • 6
  • 24

1 Answers1

0

Without another solution, my only way to do this I think would be to build and maintain an array separately outside the table instead of building it inside the table as I go along. If somebody has a better solution please post!

Chaim Friedman
  • 720
  • 6
  • 24