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 t开发者_C百科ime 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?
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.
精彩评论