Cyril
Cyril

Reputation: 1236

Displaying NSString in a label every n minutes

I am having a label and an array which consists of 10 string values.I know how to display the text in that label.But now,For every 1 minutes I want to display each and every string from that array to the label .Any idea how to do this ?

Upvotes: 0

Views: 130

Answers (3)

Hailei
Hailei

Reputation: 42163

  1. Add a variable in your class to save the index of current string
  2. Write a method which increase the index and update the label with the next string
  3. Create a NSTimer with interval = 60 seconds to call this method repeatly

Update

Per your comments I guess what you want to update is the location info? Some references:

Upvotes: 2

Prabha
Prabha

Reputation: 434

use NSTimer with 60 sec interval, write a method to get the text from the array and display it in the label.

Upvotes: 1

bontoJR
bontoJR

Reputation: 7045

Use an NSTimer

NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:60.0 target:self selector:@selector(changeText:) userInfo:nil repeats:YES];

Remember to use [timer invalidate] if you want to stop the timer, or you'll have a crash if the target has been released.

Upvotes: 3

Related Questions