Jack Nutkins
Jack Nutkins

Reputation: 1555

Calling function after thread/function completion

I would like to remove a view from another after the completion of a thread/another function in the class. At the moment I am using the following code to remove it after a set time period, but obviously, the function completion times varies

LoadingView *loadingView =
    [LoadingView loadingViewInView:self.view];

    [loadingView
     performSelector:@selector(removeView)
     withObject:nil
     afterDelay:10.0];

Is there a simple way of doing this? I've looked online and can't seem to find anything. Does this mean I have to write this functionality myself?

Upvotes: 0

Views: 409

Answers (1)

John Cromartie
John Cromartie

Reputation: 4224

You can remove a view from the other thread with:

[loadingView performSelectorOnMainThread:@selector(removeView) withObject:nil waitUntilDone:NO];

Of course you just need to maintain a reference to the loadingView somewhere that the thread can access.

Upvotes: 1

Related Questions