Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Apple Adventure LoadSceneAsets完成处理程序是否在完成时运行?_Ios_Grand Central Dispatch_Sprite Kit - Fatal编程技术网

Ios Apple Adventure LoadSceneAsets完成处理程序是否在完成时运行?

Ios Apple Adventure LoadSceneAsets完成处理程序是否在完成时运行?,ios,grand-central-dispatch,sprite-kit,Ios,Grand Central Dispatch,Sprite Kit,下面的代码取自Apple Sprite工具包冒险示例。代码的措辞建议方法[self-LoadSceneAsets];在后台执行,完成后,在主线程上执行提供的处理程序块 我的问题是:它真的这样工作吗?因为我看不到允许块在loadsceneasets完成后运行的机制。基本上,如果LoadSceneAset需要15秒才能完成,那么提供的块将等待15秒然后运行,还是在LoadSceneAset方法启动后立即开始运行 注意:这背后的想法是,在显示场景之前,加载场景的资源(SKTextures、SKSpri

下面的代码取自Apple Sprite工具包冒险示例。代码的措辞建议方法[self-LoadSceneAsets];在后台执行,完成后,在主线程上执行提供的处理程序块

我的问题是:它真的这样工作吗?因为我看不到允许块在loadsceneasets完成后运行的机制。基本上,如果LoadSceneAset需要15秒才能完成,那么提供的块将等待15秒然后运行,还是在LoadSceneAset方法启动后立即开始运行

注意:这背后的想法是,在显示场景之前,加载场景的资源(SKTextures、SKSpritodes等)并做好准备


资产加载在异步块中,当方法返回完成处理程序(如果有)时,调用完成处理程序(请参见[self-LoadSceneAsets];和handler();都是连续执行的。我感到困惑的是[自动加载场景集];和handler();都在同一时间运行,但在不同的线程上。谢谢。每个块连续运行,但可以在单独的线程上运行(例如,当使用dispatch\u async时)。所以“加载资产”块异步运行,加载完成后,处理程序块也异步运行。
#pragma mark - Shared Assets
+ (void)loadSceneAssetsWithCompletionHandler:(APAAssetLoadCompletionHandler)handler {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
        // Load the shared assets in the background.
        [self loadSceneAssets];

        if (!handler) {
            return;
        }

        dispatch_async(dispatch_get_main_queue(), ^{
            // Call the completion handler back on the main queue.
            handler();
        });
    });
}