NSTimer for UITableviewcell similar to World Clock app

不想你离开。 提交于 2019-12-05 10:40:58

One timer is sufficient. When it fires, ask the table view for the visible cells and update them one by one. You could also just call reloadData when the timer fires but depending on how you draw your cells you might do more work than necessary and you cannot use animations.

Just know that you need to schedule the timer to fire more than once a second. NSTimer isn't a precision device--you're scheduling it for the next available processor slot after the time duration you specify. So a 1 second NSTimer WON'T fire in exactly a second, and can actually accumulate quite a lot of error over time. You want it to come alive several times a second, look at the current time, notice when a second has passed, and do the UI/data updates appropriate to that fact.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!