If you are building Snow Leopard, the easiest solution, in my opinion, is to use blocks and Grand Central Dispatch.
The following code shows what your method looks like startIt:when using a GCD.
stopIt: , . , , , , , , , . , GCD. , , , , .
- (IBAction)startIt:(id)sender {
void (^progressBlock)(void);
progressBlock = ^{
[progressbar setDoubleValue:0.0];
[progressbar startAnimation:sender];
running = YES;
int i = 0;
while (running) {
if (i++ >= processAmount) {
running = NO;
continue;
}
double progr = (double)i / (double)processAmount;
NSLog(@"progr: %f", progr);
dispatch_async(dispatch_get_main_queue(), ^{
[progressbar setDoubleValue:progr];
[progressbar setNeedsDisplay:YES];
});
}
};
dispatch_queue_t queue = dispatch_get_global_queue(0,0);
dispatch_async(queue,progressBlock);
}