progressIndicator does not update till about 10 seconds after awakeFromNib occures

Posted by theprojectabot on Stack Overflow See other posts from Stack Overflow or by theprojectabot
Published on 2010-03-17T23:27:20Z Indexed on 2010/03/17 23:31 UTC
Read the original article Hit count: 518

Filed under:
|

I have been trying to get this one section of my UI to immediatly up date when the document loads into view. The awakeFromNib fires the pasted code and then starts a timer to repeat every 10 seconds...

I load a default storage location: ~/Movies... which shows up immediately.. yet the network location that is saved in the document that gets pulled from the XML only seems to show up after the second firing of the - (void)updateDiskSpaceDisplay timer.

I have set breakpoints and know that the ivars that contain the values that are being put into the *fileSystemAttributes is the network location right when the awakeFromNib occurs...

Im confused why it magically appears after the second time firing instead of immediately displaying the write values.

   - (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];
}

thoughts?

my awakeFromNib:

- (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];
}

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about mac