0

Wondering if there is an updated example of how to retrieve the file names from the assets folder and store into an array?

Sulthan
  • 128,090
  • 22
  • 218
  • 270
cackland
  • 59
  • 5
  • Likely duplicate of https://stackoverflow.com/questions/22520883/can-i-access-an-xcassets-directory-on-the-filesystem. – matt Feb 07 '19 at 18:21

1 Answers1

0

There is no "assets folder" in the built app. At build time, asset catalogs are compiled into a .car file. Thus the running app has no access to the individual images in the catalog except through the usual UIImage(named:) and similar.

You could probably write a build script to parse the assets catalog at build time and write something into your app bundle that you could load in the running app.

However, the fact that you even want to get this information is itself a Bad Smell (antipattern). You should probably ask a question about what you really want to do. For example, if your goal is provide your app with a folder full of images that you can enumerate at runtime, you would use a folder reference, not the asset catalog.

matt
  • 515,959
  • 87
  • 875
  • 1,141