在方法中运行方法而不完成



所以我有两个方法

-(void)someMethod
{
    [self someOtherMethod];
    //Do some other stuff
}
-(void)someOtherMethod
{
    //Do some other stuff
}

我想知道是否可以运行上面的代码所示的 someOtherMethod,但无需等待 someOtherMethod 完成运行才能继续。

dispatch_async(... some queue ..., ^{
    [self someOtherMethod];
});

请注意,您可以使用全局并发队列之一,但您需要注意不要敲击它,否则您最终会得到数十个线程。 您可能希望创建自己的并发串行队列并在那里排队。

相关内容

最新更新