2

我有一个 NSTextField ,当我的应用程序搜索数组时会更新:

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]]);

}

NSLog 语句可以按时正常更新,但是 NSTextField 需要一些时间来更新,并且有时会丢失一些文件编号(例如复制 Test.txt(10 分之三)然后跳转到(10 分之 9))

如何强制更新文本字段?不幸的是,没有重绘方法......:/

4

1 回答 1

2

你可以试试[progressLabel display]

于 2010-10-13T15:49:26.060 回答