iOS 9中的随需应变资源 - 如何找到下载资源的确切位置? [英] On demand resources in iOS 9 - how to find out exact location of downloaded resources?

查看:179
本文介绍了iOS 9中的随需应变资源 - 如何找到下载资源的确切位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在不使用xcassets的游戏中使用ODR。

I'm trying to use ODR in my game which doesn't use xcassets.

所以,我有一个带有标签的纹理(例如教程),在项目设置中将其作为ODR并使用下面的代码获取它:

So, I've got a texture with a tag (e.g. "tutorial"), made it ODR in project settings and used the code below the get it downloaded:

NSBundleResourceRequest *resourceRequest = [[NSBundleResourceRequest alloc] initWithTags:tags];
[resourceRequest conditionallyBeginAccessingResourcesWithCompletionHandler:^(BOOL resourcesAvailable) {
    if (resourcesAvailable) {
        // Upload the texture
    }
    else
    {
        [resourceRequest beginAccessingResourcesWithCompletionHandler:^(NSError * _Nullable error) {
            if (error) {
                NSLog(@"Failed to load assets pack");
            }
            else
            {
                // Upload the texture
            }
        }];

    }
}];

主包不包含有问题的纹理(我在模拟器中查看了包夹)。在调用上面的代码后,XCode和日志报告它已成功下载并可以使用。

The main bundle doesn't contain the texture in question (I've looked the bundle through in simulator folder). After calling the code above XCode and logs report that it was successfully downloaded and is ready to use.

注释 //上传纹理我需要调用我的代码将纹理上传到视频内存中,但问题是 - 我无法获得下载文件的确切位置。

Where the comment // Upload the texture is I need to call my code for uploading the texture into video memory, but the problem is - I can't get exact location of the downloaded file to do so.

有没有办法知道下载资产的位置?

Is there any way to know the location of downloaded assets?

推荐答案

NSBundleResourceRequest中提供了一个包您可以使用它来获取资源。请参阅 Apple的文档NSBundleResourceRequest

There is a bundle provided in NSBundleResourceRequest which you can use to get the resources. See Apple's Docs on NSBundleResourceRequest

这篇关于iOS 9中的随需应变资源 - 如何找到下载资源的确切位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆