Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Blakeasd

macrumors 6502a
Original poster
Dec 29, 2009
643
0
I added a folder to Xcode with a collection of images, 456 images to be precise. I need to add these images to an NSMutableArray so I can later view them in an IKImageBrowserView. I could add each of these images manually to the NSMutableArray, but that would take a very long time. How can I access folders that are used by my program and add them to an NSMutableArray?
Thanks
 
I added a folder to Xcode with a collection of images, 456 images to be precise. I need to add these images to an NSMutableArray so I can later view them in an IKImageBrowserView. I could add each of these images manually to the NSMutableArray, but that would take a very long time. How can I access folders that are used by my program and add them to an NSMutableArray?
Thanks

Why would it take a long time? This is what loops are for.
 
You are vague with "added a folder to Xcode", so I will ask, did you add it to the project? Have you checked to see if these images are being copied into your application bundle? If so, then they are probably in Contents/Resources, and if they are distinct from everything else in /Resources, then you can enumerate that (filtering for only these images), and work from there.
 
You should use [[NSBundle mainBundle] resourcePath] to locate your application's resource directory. Then you can use a NSFileManager method to either create an array of filenames from your subdirectory (by appending the folder name to the resource path as a path component) or create a directory enumerator. If you image folder has subfolders itself, you would use the directory enumerator to go through them easily, filtering out the folder names as you go.

As far as it being "manual", you only have to do it once.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.