• 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
Re: Problems with NSTimer and NSRunLoop/CFRunLoop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with NSTimer and NSRunLoop/CFRunLoop


  • Subject: Re: Problems with NSTimer and NSRunLoop/CFRunLoop
  • From: Brendan Younger <email@hidden>
  • Date: Thu, 06 Jan 2005 20:18:43 -0600

Not all of CF is open-source, only the relatively uninteresting parts. =) The code John posted should work, but it's unnecessary. Although, how do you know that you timer isn't being added to the run loop? You might be trying to add the timer to a run loop that's never being run (i.e. in another thread). If you really get desperate, you can pose as NSRunLoop via something like this:

@interface MyRunLoop : NSRunLoop {
}

@end

@implementation MyRunLoop

- (id)init {
	if(!(self = [super init]))
		return nil;

	NSLog(@"Created run loop %p", self);

	return self;
}

- (void)addTimer:(NSTimer*)inTimer forMode:(NSString*)inMode {
	[super addTimer:inTimer forMode:inMode];

NSLog(@"Added timer %@ to run loop %p for mode %@", inTimer, self, inMode);
}


@end

and call [MyRunLoop poseAsClass:[NSRunLoop class]] before the call to NSApplicationMain(). If that doesn't help, I don't know what to suggest.

Brendan Younger

On Jan 6, 2005, at 7:58 PM, John Stiles wrote:

Try using
	NSTimer      *timer = [NSTimer scheduledTimerWithTimeInterval:120
                target:self
                selector:@selector(performExpirationCheck:)
                userInfo:nil
                repeats:YES];

[[NSRunLoop currentRunLoop] addTimer: timer forMode:NSDefaultRunLoopMode];

And you do know that CF is all open source, right?


On Jan 6, 2005, at 5:52 PM, Mont Rothstein wrote:

I have a timer that is not being added to the run loop, and for the life of me I can't figure out why.

I call:

[NSTimer scheduledTimerWithTimeInterval:120
                target:self
                selector:@selector(performExpirationCheck:)
                userInfo:nil
                repeats:YES]

And, I verified that this calls:

CFRunLoopAddTimer

but when the call to NSTimer returns the run loop does not have the timer added.

Does anyone have any idea what might be going on, or even a suggestion on how to debug this? (man would I kill for all of the Cocoa/CF code to be open-source!)

_______________________________________________ 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
  • Follow-Ups:
    • Re: Problems with NSTimer and NSRunLoop/CFRunLoop
      • From: John Stiles <email@hidden>
References: 
 >Problems with NSTimer and NSRunLoop/CFRunLoop (From: Mont Rothstein <email@hidden>)
 >Re: Problems with NSTimer and NSRunLoop/CFRunLoop (From: John Stiles <email@hidden>)

  • Prev by Date: Re: Customising the behaviour of an NSTextFieldCell in an NSTableView
  • Next by Date: Re: Problems with NSTimer and NSRunLoop/CFRunLoop
  • Previous by thread: Re: Problems with NSTimer and NSRunLoop/CFRunLoop
  • Next by thread: Re: Problems with NSTimer and NSRunLoop/CFRunLoop
  • Index(es):
    • Date
    • Thread