I am currently trying to implement Apple's API for On Demand Resource Management for AWS Cloudfront because Apple's ODR is somehow too unreliable.
I noticed that when I tag images inside of Assets.scnassets/ with an ODR resource tag, I can access that image using
UIImage(name: resourceName)
once it has been downloaded by a NSBundleRequest object. Because I can access the downloaded resource as a 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? The most important aspect is being able to create UIImages using this incredibly simple interface.
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?
It’s an illusion. ODR files are downloaded to a directory outside the app bundle, and calls like UIImage init(named:)
are swizzled to look in that directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With