• 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
NSRunLoop behavior
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSRunLoop behavior


  • Subject: NSRunLoop behavior
  • From: Rafael Cerioli <email@hidden>
  • Date: Tue, 21 Sep 2010 07:55:04 -0400

Hi,

I'm trying to understand how run loops work. I've written this useless piece of code and I'm not sure why "success" does not show up...
What happens is that waitUntilReady never terminates, because it seems that the runUntilDate in myButtonAction never ends as well.

My theory would be that calling a runUntilDate from myButtonAction (myButtonAction is started by a run loop observer)  will just prevent other sources and observers in the *current* run loop's loop (or run loop's run ??) to be processed until myButtonAction terminates.

So, waitUntilReady's call to runUntilDate would prevent the end of myButtonAction's current run loop's loop.

Does someone have more info about that ?

- (void) myButtonAction {
	// A button event has been sent, waking up the run loop and calling that method

	// this will be called in 1 second
	[self performSelector:@selector(waitUntilReady) withObject:nil afterDelay:1];

	// process the current run loop during 10 seconds :
	[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:10]];

	[self setReady:YES];
}




- (void) waitUntilReady {

	while(![self isReady]) {
		// this should just process the run loop once :
		[[NSRunLoop currentRunLoop]  runUntilDate:[NSDate date]];
	}

	NSLog(@"success!");
}



Thank you,
Rafael_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSRunLoop behavior
      • From: Keary Suska <email@hidden>
  • Prev by Date: RE: php and cocoa
  • Next by Date: Lyrics in an application
  • Previous by thread: RE: php and cocoa
  • Next by thread: Re: NSRunLoop behavior
  • Index(es):
    • Date
    • Thread