当文档加载到视图中时,我一直在尝试让我的UI的这一部分立即更新。awakefromnib触发粘贴的代码,然后启动计时器,每10秒重复一次…
我加载默认存储位置:~/电影…马上就会出现……然而,保存在从XML中提取的文档中的网络位置似乎只在第二次触发-(void)updatediskspacedisplay计时器后出现。
我已经设置了断点,并且知道包含要放入*文件系统属性中的值的ivar是发生awakefromnib时的网络位置…
我很困惑为什么它会在第二次触发后神奇地出现,而不是立即显示写入值。
- (void)updateDiskSpaceDisplay
{
// Obtain information about the file system used on the selected storage path.
NSError *error = NULL;
NSDictionary *fileSystemAttributes = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[[[self settings] containerSettings] storagePath] error:&error];
if( !fileSystemAttributes ) return;
// Get the byte capacity of the drive.
long long byteCapacity = [[fileSystemAttributes objectForKey:NSFileSystemSize] unsignedLongLongValue];
// Get the number of free bytes.
long long freeBytes = [[fileSystemAttributes objectForKey:NSFileSystemFreeSize] unsignedLongLongValue];
// Update the level indicator, and the text fields to show the current information.
[totalDiskSpaceField setStringValue:[self formattedStringFromByteCount:byteCapacity]];
[totalDiskSpaceField setNeedsDisplay:YES];
[usedDiskSpaceField setStringValue:[self formattedStringFromByteCount:(byteCapacity - freeBytes)]];
[usedDiskSpaceField setNeedsDisplay:YES];
[diskSpaceIndicator setMaxValue:100];
[diskSpaceIndicator setIntValue:(((float) (byteCapacity - freeBytes) / (float) byteCapacity) * 100.0)];
[diskSpaceIndicator display:YES];
}
思想?
我的灵感来自笔尖:
- (void)awakeFromNib
{
[documentWindow setAcceptsMouseMovedEvents:YES];
[documentWindow setDelegate:self];
[self updateSettingsDisplay];
[self updateDiskSpaceDisplay];
[self setDiskSpaceUpdateTimer:[NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:@selector(updateDiskSpaceDisplay) userInfo:NULL repeats:YES]];
[self setUpClipInfoTabButtons];
[self performSelector:@selector(setupEngineController) withObject:NULL afterDelay:0.1];
}