• 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
Getting NSTimer to work after an NSThread completes?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting NSTimer to work after an NSThread completes?


  • Subject: Getting NSTimer to work after an NSThread completes?
  • From: Alex Reynolds <email@hidden>
  • Date: Tue, 7 Oct 2008 01:06:29 -0700

When I press my interface button, it calls:

[NSThread detachNewThreadSelector:@selector(initializeData) toTarget:self withObject:nil];

This calls:

	- (void) initializeData
	{
		NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

		... initialize data ...

[[NSNotificationCenter defaultCenter] postNotificationName:DataAreInitializedNotification object:self];
[pool release];
}


The notification 'DataAreInitializedNotification' instantiates and brings a new view to the foreground, immediately after the data are initialized.

The new view shows up fine. The problem is that if I instantiate an NSTimer in this new view, the NSTimer never fires my selector:

[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(doSomethingInteresting:) userInfo:nil repeats:NO]

However, if I skip the NSThread instantiation step, then my NSTimer starts working again.

I have also tried:

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

in my new view, but this does not work either.

What should I do to get an NSTimer to work after an NSThread completes?

Thanks,
Alex
_______________________________________________

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: Getting NSTimer to work after an NSThread completes?
      • From: Jason Coco <email@hidden>
  • Prev by Date: Re: NSWindowController retain counts, chapter 2
  • Next by Date: Re: Getting NSTimer to work after an NSThread completes?
  • Previous by thread: Re: comparing Strings.
  • Next by thread: Re: Getting NSTimer to work after an NSThread completes?
  • Index(es):
    • Date
    • Thread