Is there an easy way to update progressbar as code runs

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?


ANSWERS:


After doing some digging, the UI can be updated asynchronously through for loops with the following code:

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {
    for(int i=0; i<max; i++)
    {
        //Run for loop stuff here

        dispatch_async(dispatch_get_main_queue(), ^(void) {
           //Run UI updates in here 
        });
    }
});


 MORE:


 ? NSProgressIndicator not showing progress
 ? Can NSTableView column bound to coredata Entity NSArrayController in secondary thread work?
 ? Displaying file copy progress using FSCopyObjectAsync
 ? Displaying file copy progress using FSCopyObjectAsync
 ? Displaying file copy progress using FSCopyObjectAsync
 ? Recommended way to copy arbitrary files using Cocoa
 ? Stop NSFileManager process
 ? Showing File Copy Status on a Progress Bar
 ? Adding an NSProgressIndicator to the dock icon
 ? Adding an NSProgressIndicator to the dock icon