views:

82

answers:

2

I have a simple UILabel on that I want to change the text of every 10 seconds. What is the best way of doing this, which let's the rest of the interface remain active?

+1  A: 

All you need is to start an NSTimer and update the label.text each time.

progrmr
+3  A: 
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:10.0f target:self selector:@selector(updateLabel:) userInfo:nil repeats:YES];
self.repeatingTimer = timer;
...

- (void) updateLabel:(id)sender {
    myLabel.text = newStringValue;
}

...
[repeatingTimer invalidate];
self.repeatingTimer = nil; // stops timer
Alex Reynolds