List folders inside Assets.xcassets

I have created folders inside my Assets.xcassets.

So I can organize images and group them as "set"


Assets.xcasset
| Set1 (folder)
| | Birds (folder)
| | | image1
| | | image2
| | | image3
| | | image4
| | Foo (folder)
| | Bar (folder)


I would like to use these folders in code (swift) so I can:

  1. list all folders in "Set1"
  2. pick one folder randomly
  3. Load all images of that folder in a [UIImage]


But I can't find a way to list these folders


So here are my questions:

- Is it possible to use folders created inside Assets.xcassets to do the step 1. and 3. ?

- If it is not (well what a usefull folder feature then 😝), what would be the (elegent, easy to maintain/update) way to do that?


the cool thing by doing that is that:

- the code would be agnostic of how many sets they are (there should be many 20+)

- the code would be agnostic of name of images in these sets

- it is easy to maintain, few lines of codes, almost no hardcoded names/ref anywhere

The project targets iOS platform

Replies

What color are your folders? Yellow or blue?