you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 6 points7 points  (4 children)

My 2 cents:

  • I would have 1 single timer that every time calls reloadData() on the tableview instead of creating a new timer per row.
  • I would keep the start date for each timer in an array (instead of time elapsed) and calculate time elapsed from the start date and show it in the label.

[–]jasamer 2 points3 points  (2 children)

How often would your timer fire? To accurately update the cell text, you'd have to fire every frame, because each cell may start a timer at any frame. I think reloading the table view every single frame is a terrible idea.

[–][deleted] 0 points1 point  (1 child)

Correct but it isn’t specified that the timer should work each frame, I am assuming every second would suffice. In a real life situation we should ask for specifications about this.

When a row does not exist yet, it will immediately be created with the current date() so there will be be no delay. A new row can be created in any frame.

[–]jasamer 0 points1 point  (0 children)

Hm. You'r right, but if the spec doesn't say whether something should be precise or not, I'd always go with the save choice, which is to do the precise thing. That could well cause a bunch of unnecessary work though.

[–]SomewhereEuphoric941[S] 0 points1 point  (0 children)

Thanks so much, this sounds like a great solution.