I have this NSMutable array. Reading it one by one after every two seconds and updating textview. But now i want is to read from NSMutable array one by one at different timeintervals than every two seconds. How i can do that.
- (void)viewDidLoad{
myArray = [[NSMutableArray alloc]initWithObjects:@"String1",@"String2",@"String3",@"String4", @"String5",..... nil];
[NSTimer scheduledTimerWithTimeInterval:2.0
target:self
selector:@selector(updateText:)
userInfo:nil
repeats:YES];
- (void)updateText:(NSTimer *)theTimer
{
if (index < [myArray count])
{
myTextView.text = [myArray objectAtIndex:index];
index++;
}
else
index = 0;
}
}
Thanks for help.
If all you need is to change the interval value every time the view loads you can try with a random number, in the next example it’ll return a random number between 2 and 10: