I understand that to get images from the asset catalog, I can use UIImage (named: "fileName") to do this.
however, what if I get DATA from the XCAsset directory? I can’t figure it out.
I tried,
let url = NSBundle.mainBundle().URLForResource("fileName", withExtension: nil) let data = NSData(contentsOfURL: url!)
But this is zero. I do not know how to get data from the XCAssets directory. If anyone can help me (google search didn’t help), please let me know, I will be very grateful!
Update:
Why am I trying to get data from the asset catalog? I dragged the animated gif into the asset directory. And the asset catalog interprets this as DATA. This is why I am trying to get data from the asset catalog.
Update: This image on the screen of my Assets.xcassets folder looks like.
It has a file called "_Loading", and on the right it is considered a "Data set". I'm not sure how to get the dataset from the Assets directory.
ios swift xcasset asset-catalog
DerrickHo328
source share