views:

60

answers:

1

Hi all,

I have a problem that i want to call a function when one of my functions that is running into a seperate thread comes to an end:

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

here is my fetchFeaturedFreeApps function

-(void)fetchFeaturedFreeApps
{
    ////all my code
    [self performSelector:@selector(closeView) withObject:nil afterDelay:4.0];
}

My problem is that the close view methods doesnt run after the 4 seconds.

Hoew if i call the fetchFeaturedFreeApps method with perform selector then my closeview metod is called properly.

Your valuable help is highly appreciated.

+3  A: 

You want to run any UI or view update code in a selector that runs on the main thread, not in a background thread. Use -performSelectorOnMainThread:withObject:waitUntilDone: and place a timer in that selector to fire after four seconds, which closes your view.

Alex Reynolds