NSThread Question
NSThread Question
- Subject: NSThread Question
- From: Lorenzo Puleo <email@hidden>
- Date: Tue, 23 Apr 2002 19:45:02 +0200
I should have to run/stop a cycle using the same button.
I would like to break the loop at any time pressing the same button.
But when I press the button to start the loop, I can't press again the
button to stop the loop. I have to wait the loop ends...
Also, the button still appears blue-pressed...
I understand I have to use NSThread, but I don't understand how I can do
this using my current routine since NSThread requires methods (+) which
don't allow to manipulate variable instances and factories within
theirselves as, instead, I have to do.
Any ideas would be greatly appreciated as I am relatively
new to Cocoa. Thanks.
My current loop would be: (it doesn't work as I want)
- (IBAction)ExecuteLoop
{
int i;
if(isRunning == YES){
// isRunning is a variable instance of this class
isRunning = NO;
return;
}
isRunning = YES;
// gItemsToDoArray is a variable instance of this class
for(i = 0; i<[gItemsToDoArray count]; i++){
if(isRunning == NO) break;
[self processTheItem:[gItemsToDoArray objectAtIndex:i]];
}
// This shows an alert telling how much items
// were been processed
[self showReport:i];
}
--
Lorenzo Puleo
mailto:email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.