Accessing Xcode Folder in NSMutableArray?

Discussion in 'Mac Programming' started by Blakeasd, May 1, 2011.

  1. Blakeasd macrumors 6502a

    Dec 29, 2009
    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?
  2. Cromulent macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
    Why would it take a long time? This is what loops are for.
  3. larkost macrumors 6502a

    Oct 13, 2007
    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.
  4. chown33 macrumors 604

    Aug 9, 2009
    on the Western Slopes, with E. A. Poe
    NSFileManager. The Discovering Directory Contents methods.
  5. Sydde macrumors 68020


    Aug 17, 2009
    Velvet Green
    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.
  6. Blakeasd thread starter macrumors 6502a

    Dec 29, 2009

Share This Page