The easiest way to load a local UIImage
asset is of course to use +[UIImage imageNamed]
but for my case, I want to supply a NSURL *
. How do I get a NSURL *
for local file?
While using xcasset, Xcode put all your files in a new one. 1 file to manage them all. So, you can't access to an image store inside an xcasset directly. From apple's documentation:
For projects with a deployment target of at least iOS 7 or OS X 10.9, Xcode compiles your asset catalogs into a runtime binary file format that reduces the download time for your app.
If you have to access to the file, you have two choice:
NSBundle
to get itUIImage imageNamed
, and save it in the directory of your choiceBut whatever your need, you should think another way to manage it. The above solutions will work, but I'm sure you can have a nicer solution.
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