views:

89

answers:

2

Hi guys,

I want to run a method in a background thread, the first method will run another method on the same (background) thread after some seconds. I wrote this:

- (IBAction)lauch:(id)sender
{
    [self performSelectorInBackground:@selector(first) withObject:nil];

}
-(void) second {
    printf("second\n");
}
-(void) first {
    NSAutoreleasePool *apool = [[NSAutoreleasePool alloc] init];
    printf("first\n");

    [self performSelector:@selector(second) withObject:nil afterDelay:3];

    printf("ok\n");
    [apool release];
}

but the second method is never called, why? and, how may i accomplish my goal?

thanks

A: 

You have to have a running run loop for performSelector:withObject:afterDelay: to work.

Do you?

bbum
ouch... no. That should be the problem. Thanks!
subzero
A: 

I too have a same problem,If u found please post it here

Dinesh Kumar
Hi!, as bbum said, it's necessary to configure an run a NSRunLoop on that thread.
subzero