views:

43

answers:

2

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];
}
+1  A: 

awakeFromNib is only a notification to your instance that its IBOutlets have been set up, not that the application has finished launching and is ready to draw.

Try implementing NSApplication's delegate method, applicationDidFinishLaunching:, and call your updateDiskSpaceDisplay method from there.

tedge
will try thanks.
theprojectabot
can I run that delegate method on a subclass of NSDocument?
theprojectabot
A: 

there was an read from xml method that was occurring after my awakeFromNib that was swizzling the values... I just put the updateDiskSpaceDisplay there and... problem solved. Thanks all for the attempts.

theprojectabot