2

I have about 1500 images that are used in my app, they are similar to clip art. I wanted to know what the best way to store these is, and the way to loop through that folder to list all of the image names and paths.

Is it best to store all images in my app bundle? If so, how do I then list all contents at that directory path?

Is there a better alternative to this?

jscs
  • 63,694
  • 13
  • 151
  • 195
Nic Hubbard
  • 41,587
  • 63
  • 251
  • 412

1 Answers1

1

As long as you stay under the size limits putting the images into your app bundle sounds like a valid choice.

You can use NSBundle's pathsForResourcesOfType:inDirectory: API to list paths for items with a specific extensions inside your bundle. If you adopt a naming scheme where a path name encodes the name that you want to give your image in the list, you can implement a simple method that extracts image name from a resource path name.

Community
  • 1
  • 1
Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523
  • Ok, but say I would rather just create a folder in my file system and put them in there, rather than bringing them into Xcode. Is this possible? – Nic Hubbard May 14 '12 at 23:17
  • @NicHubbard But the resource files are already put in a folder on your file system - specifically, they go in the same directory with your application. This is the right place for the files of this kind - `documents` are for user content, `library` is backed up to Mac/PC, and `temp` is periodically purged. – Sergey Kalinichenko May 15 '12 at 00:28