ios - Apple 的 On Demand Resource System 如何将文件下载到 App 的 Main Bundle 中?

标签 ios swift bundle on-demand-resources

我目前正在尝试为 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/

相关文章:

iphone - 使用带有iOS模拟器的内置相机的mac book

ios - 从对象数组中检索值

android - 从android中的包中检索数据

Android:无法保存和读取 Bundle 中的所有值

swift - Cocoa Swift - 取消 FileManager 的任务

Symfony EasyAdmin bundle 一对多

iphone - 滚动时 UITableView 重绘问题

ios - Swift/IOS 如何使用观察者进行更新

ios - 我想在 ios 中使用具有不同数据的相同 UserInterface

swift - 如何使用 SpriteKit AR 在 Swift 中的 SKScene 上创建覆盖 SCNScene?