I have a table view with 5 rows. The first row shows a decreasing digit indicating the time in seconds, i.e 30, 29, 28 ... 0. This is for the user to choose an action from the table view within 30 seconds. How is this implemented?
Should be a comment.
Stefan Kendall
2009-08-14 20:11:46
A:
Set up a repeating NSTimer that fires once a second and invalidates after thirty seconds. Each time it fires, it should update the relevant table cell. Because NSTimers may not fire quite when their supposed to (and in some cases can be significantly delayed), I don't recommend using its firing to keep track of how much time has passed. Instead, at the beginning of the countdown, note the time that will be 30 seconds in the future. Your cell should then display that time minus the current time. When the NSTimer fires, update the cell by again calculating your end time minus the current time. When the value gets to zero, invalidate the timer.
Rob Napier
2009-08-17 03:05:36