Pripyat
Pripyat

Reputation: 2937

Force update of NSTextField

I have a NSTextField that gets updated when my app searches through an array:

for (NSString *file in fileinDir)
{
        processedFiles = processedFiles + 1;

        NSArray*filesinDevice = [fm contentsOfDirectoryAtPath:[[dict objectForKey:NSWorkspaceVolumeURLKey] path] error:nil];

        [progressLabel setStringValue:[NSString stringWithFormat:@"Copying %@ (%i out of %i)",file,processedFiles,[filesinDevice count]]];

        NSLog(@"%@",[NSString stringWithFormat:@"Copying %@ (%i out of %i)",file,processedFiles,[filesinDevice count]]);

}

The NSLog statement updates fine and on time, but the NSTextField takes some time to update and sometimes misses out some file numbers ( like saying Copying Test.txt (3 out of 10) and then jumping to (9 out of 10))

How can I force update the text field? There's no redraw method unfortunately... :/

Upvotes: 2

Views: 1989

Answers (1)

Nick Moore
Nick Moore

Reputation: 15857

You could try [progressLabel display]

Upvotes: 2

Related Questions