• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSThread Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: NSThread Question
      • From: Drew McCormack <email@hidden>
    • Re: NSThread Question
      • From: "Erik M. Buck" <email@hidden>
  • Prev by Date: Ways of optimization
  • Next by Date: Re: My cocoa app don't run on other computers
  • Previous by thread: Re: Ways of optimization
  • Next by thread: Re: NSThread Question
  • Index(es):
    • Date
    • Thread