On demand resources in iOS 9 - how to find out exact location of downloaded resources?

被刻印的时光 ゝ 提交于 2020-01-12 08:05:51

问题


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

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
            }
        }];

    }
}];

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?


回答1:


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



来源:https://stackoverflow.com/questions/33824528/on-demand-resources-in-ios-9-how-to-find-out-exact-location-of-downloaded-reso

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!