开发者

Calling function after thread/function completion

开发者 https://www.devze.com 2023-03-06 18:09 出处:网络
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,

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消