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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to