troubles with a progress bar updating
troubles with a progress bar updating
- Subject: troubles with a progress bar updating
- From: Jeff Childers <email@hidden>
- Date: Sun, 11 Dec 2005 13:11:14 -0600
I cant seemed to get my progress bar to update. When I create the
object I tried to
set it to 50% but it won't update.
At the bottom I have the nslog's I put in the code.
#import "MyProgressIndicator.h"
@interface WindowController : NSObject
{
...
MyProgressIndicator* thisProgress;
...
}
@end
@implementation WindowController
-(void)awakeFromNib{
thisProgress = [[MyProgressIndicator alloc] init];
NSLog(@"loaded");
}
--------------------------------------------------------
@interface MyProgressIndicator : NSObject
{
IBOutlet id progressBar;
int currentProgress;
int incrementer;
}
- (void)initProgressBar:(int)totalGeneration;
- (void)advanceProgressBar;
- (void)resetProgressBar;
@end
@implementation MyProgressIndicator
// init
- (id)init
{
if (self = [super init]) {
currentProgress = 0.0;
[progressBar setDoubleValue:50.0]; //tried to set it when the
object was created
[progressBar displayIfNeeded];
[progressBar display];
NSLog(@"object created");
}
return self;
}
//===========================================================
// currentProgress
//===========================================================
- (void)initProgressBar:(int)totalGeneration
{
incrementer = (100 / totalGeneration);
[progressBar setDisplayedWhenStopped:YES];
NSLog(@"progressbar init %d %i",incrementer,totalGeneration);
}
- (void)advanceProgressBar
{
[progressBar incrementBy:incrementer];
[progressBar setDoubleValue:currentProgress];
currentProgress += incrementer;
[progressBar displayIfNeeded];
[progressBar display];
NSLog(@"progressbar advance %i",currentProgress);
}
- (void)resetProgressBar
{
[progressBar setDoubleValue:0.0];
currentProgress = 0.0;
incrementer = 0.0;
[progressBar displayIfNeeded];
NSLog(@"progressbar reset");
}
//===========================================================
// dealloc
//===========================================================
- (void)dealloc
{
[progressBar release];
NSLog(@"dealloc progressbar");
progressBar = nil;
[super dealloc];
}
@end
MY NSLOG OUTPUT
2005-12-11 12:54:35.040 ttc[1319] object created
2005-12-11 12:54:35.076 ttc[1319] object created
2005-12-11 12:54:35.089 ttc[1319] loaded
2005-12-11 12:54:41.547 ttc[1319] max 10
2005-12-11 12:54:41.559 ttc[1319] progressbar init 10 10
2005-12-11 12:54:41.559 ttc[1319] progressbar advance 10
2005-12-11 12:54:41.559 ttc[1319] progressbar advance 20
2005-12-11 12:54:41.559 ttc[1319] progressbar advance 30
2005-12-11 12:54:41.559 ttc[1319] progressbar advance 40
2005-12-11 12:54:41.560 ttc[1319] progressbar advance 50
2005-12-11 12:54:41.560 ttc[1319] progressbar advance 60
2005-12-11 12:54:41.560 ttc[1319] progressbar advance 70
2005-12-11 12:54:41.560 ttc[1319] progressbar advance 80
2005-12-11 12:54:41.560 ttc[1319] progressbar advance 90
2005-12-11 12:54:41.561 ttc[1319] progressbar advance 100
2005-12-11 12:54:41.561 ttc[1319] progressbar reset
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden