Say I have to update a label 1000 times a minute. Completely change its string value. Am I best off making 1000 setText:
calls per minute? Or is there a more efficient way? Perhaps doing away with labels completely?

- 314,917
- 42
- 532
- 579

- 29,668
- 57
- 204
- 388
3 Answers
You basically have two options - update the text
property of a UILabel
or draw an NSString
directly onto a UIView
(after first erasing the previous value). You'll have to run some tests to see which is more efficient.

- 314,917
- 42
- 532
- 579
You can update some local field/variable and use Timer which read value from variable as frequent as it necessary and update Label. You can also use some throttle strategies. I'm not an iOS expert so I say what my intuition says to me.

- 627
- 6
- 14
I've used this github library in one of my projects https://github.com/dataxpress/UICountingLabel, which basically subclasses a UILabel and counts down from some initial value to some final value with a custom duration that you can specify, and it is quite efficient and smooth. You can have a look at their code and it might help.

- 2,715
- 1
- 17
- 17