Hi there!
I'm working in an app that uses a UIView. Inside this UIView there is a UILabel properly declared as a property of the UIView's viewController. In fact the app is a simple backtracking functions test (no commercial use, just for fun hehe). I'm logging each backtracking step (the made "path") in the console, but I want it to be logged in the UILabel. However, though I'm changing the UILabel's text in my loop functions, it doens't get refreshed until the whole function is ended. I'm doing a more simple test with a simple loop (no backtracking yet) to try get the UILabel updated at every loop, here it is:
Code:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSString *str;
for (int i=0; i<99999; i++) {
str = @"";
str = [str stringByAppendingFormat:@"%d",arc4random() % 10];
str = [str stringByAppendingFormat:@"%d",arc4random() % 10];
str = [str stringByAppendingFormat:@"%d",arc4random() % 10];
str = [str stringByAppendingFormat:@"%d",arc4random() % 10];
str = [str stringByAppendingFormat:@"%d",arc4random() % 10];
str = [str stringByAppendingFormat:@"%d",arc4random() % 10];
str = [str stringByAppendingFormat:@"%d",arc4random() % 10];
str = [str stringByAppendingFormat:@"%d",arc4random() % 10];
str = [str stringByAppendingFormat:@"%d",arc4random() % 10];
str = [str stringByAppendingFormat:@"%d",arc4random() % 10];
[self.lblMain setText:str];
}
}
And yes, the label is declared as a property, IBOutlet, correctly associated with the IB's UILabel, and seems that everything have to work well, but it's like if the screen just get updated when a function is finished so my label just shows: "Paths" just before touching the screen and, when I touch it, it just "freezes" during the loop and after that just shows the last number...
EDIT: And yes, I've already tried [self.view setNeedsDisplay] and it doesn't make a change...
Is there any kind of "[self.view refresh]" function or something like this?
Thanks in advance!