Get array of all images in asset catalog folder
Asked Answered
I

1

13

In iOS is it possible to get an array of images (or image names) that are inside a folder of an asset catalog?

If so, how?

I'm not really sure why there is a down vote on this. I really have no idea where to start.

My alternative is to create a plist of all the files in the folders but it just seems redundant.

I can't add any code because what would I add?

Would love to get feedback on why there is a down vote though.

Interlunation answered 16/6, 2014 at 10:0 Comment(8)
And why exactly would you like to do this?Dorinda
Isn't it possible to iterate through the files in the Images.xcassets-folder?Threatt
@LordZsolt so I can display them in a table for instance. Not sure why it matters though?Interlunation
@Threatt sounds promising. Is it just a normal folder in the app bundle? I'll take a look for how to do this.Interlunation
@Interlunation I'm asking since your question is a bit weird. I can't imagine this being needed in any real use case.Dorinda
@LordZsolt I assure you my app is very real and I am required to display a list of images in a collection view. This list of images is never updated or changed. It's part of the app bundle. Seems an odd way to answer a question on stack overflow though. If everyone only answered the question they thought would have a valid use case in their own apps then none of the questions would get answered.Interlunation
Hmm seems that you need to get in to Assets.car somehow. Not sure if that it possible...Threatt
@Fogmeister, I'm facing a very similar issue to you in my other thread: #27564950. Have you found the solution, and if so, can you assist me with mine? ThanksFizz
E
-1

Of course, you can read the directories that your app owns, you can create/remove..

You can start reading NSFileManager documentation at https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/index.html

You can download the related source code as examples and see how this is done.

I hope this helps.

Elgon answered 29/10, 2014 at 12:46 Comment(1)
But the asset catalogs are compiled into a .car file. That means that there are no folders during runtime....Zootechnics

© 2022 - 2024 — McMap. All rights reserved.