Possible Duplicate:
NSProgressIndicator progress with For loops?
I have a simple question this time (hopefully). I have an NSProgressIndicatorView (progress bar) and I want to update its value and a status label as a for loop runs:
for(int i=0; i<[nameArr count]; i++)
{
NSString* str = [nameArr objectAtIndex:i];
[text setStringValue:str];
[status setStringValue:[NSString stringWithFormat:@"Processing names...%d of %ld",(i+1),[nameArr count]]];
[progress setDoubleValue:i];
}
This code works, but the status label and the progress bar do not update until the entire for loop has finished. I can watch things work as it runs if I send them as an NSLog
, so I assume there should be an easy way (without creating an NSOperation
) to similarly update my status label and progress bar as I go.
Any ideas?