Getting NSTimer to work after an NSThread completes?
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