Reputation: 6413
I'm developing app, which having timers on UITableViewCell
. But how can i do this, each cell is running different timers and its dynamic, i'm getting it from Server. How to implement this timer, in UITableViewCell
. Do i need to create any NSOperationQueue
. Can anyone help me to find solution.
Thanks,
Upvotes: 0
Views: 1142
Reputation: 11026
I have done this in one of my application, so I will share and hope it will be helpful to you.
1. Implement + scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:
function.
2. Create custom class for UITableViewCell and create a method in it where you can update the timer label.
3. Inside timer function find out tableview visible rows and call your custom UITableViewCell class method which will update only your updated text so it will optimize your performance.
Upvotes: 1
Reputation: 1195
Your timers cannot be completely in the UITableViewCells, because they get recycled. Your tableview data source should keep the time for each cell. Use NSTimer
+ scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:
to regularly update the timer views/labels.
Upvotes: 2