I have a program that runs through a while loop and updates some UILabels. However, the UILabels do not actually appear updated. Here is the while loop that updates the labels:
The "updateCells" function is the one that actually updates the UILabels, with the following line:
However, when I add the following code to the end of the while loop of "runSimulation":
then the UILabels are updated as I expected. I am guessing that the program will not update a UILabel while it is going through a while loop. How can I make the program update the UILabels during a while loop?
Code:
- (void)runSimulation {
[theModel randomize:50];
simulationPaused = false;
while(!simulationPaused) {
[theModel calculateNextGeneration];
[theView updateCells];
}
}
The "updateCells" function is the one that actually updates the UILabels, with the following line:
Code:
((UILabel*)[[labelArray objectAtIndex:i] objectAtIndex:j]).backgroundColor = [UIColor grayColor];
However, when I add the following code to the end of the while loop of "runSimulation":
Code:
simulationPaused = true;
then the UILabels are updated as I expected. I am guessing that the program will not update a UILabel while it is going through a while loop. How can I make the program update the UILabels during a while loop?