我目前正在尝试为 AWS Cloudfront 实现 Apple 的按需资源管理 API,因为 Apple 的 ODR 在某种程度上太不可靠了。
我注意到,当我使用 ODR 资源标记在 Assets.scnassets/中标记图像时,我可以使用以下方法访问该图像
UIImage(name: resourceName)
一旦它被 NSBundleRequest 对象下载。因为我可以将下载的资源作为 UIImage 访问,所以我知道该资源位于应用程序的主包中,但我认为这是不可能的,因为包是只读的。苹果是怎么做到的?最重要的方面是能够使用这个极其简单的界面创建 UIImage。
最佳答案
I know that the resource is located in the app's main bundle but I thought this was impossible because Bundles were read-only. How did apple do this?
这是错觉。 ODR 文件被下载到应用程序包之外的目录,并且像 UIImage init(named:)
这样的调用被调配以在该目录中查找。
关于ios - Apple 的 On Demand Resource System 如何将文件下载到 App 的 Main Bundle 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51384703/