我有一个GCD
背景。我有一个按钮,按下时我希望它在 GCD 完成时加载加载等待屏幕,然后在该按钮上执行其余代码。附上样品。
我的不工作,我基本上想说,等待完成GCD,同时加载等待消息,完成后继续代码。
谢谢
- (IBAction)btnTapped:(id)sender
{
shouldCancel=NO;
dispatch_queue_t existingQueque = dispatch_get_main_queue();//finds the current GCD, the one I created in a different method
dispatch_group_t group =dispatch_group_create();
dispatch_group_async(group, existingQueque, ^
{
dispatch_group_wait(group, DISPATCH_TIME_FOREVER);//does not work, I guess group can't be created here.
[self performSelectorOnMainThread:@selector(showWaitViewWithMessage:) withObject:@"Loading" waitUntilDone:YES];//load this until GCD queque done
[self performSelector:@selector(performSearch) withObject:nil afterDelay:0];
});
}