Accessing Xcode Folder in NSMutableArray?

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

  1. macrumors 6502a

    Joined:
    Dec 29, 2009
    #1
    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
     
  2. macrumors 603

    Cromulent

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

    Joined:
    Oct 13, 2007
    #3
    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. macrumors 603

    Joined:
    Aug 9, 2009
    #4
    NSFileManager. The Discovering Directory Contents methods.
     
  5. macrumors 68000

    Sydde

    Joined:
    Aug 17, 2009
    #5
    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. thread starter macrumors 6502a

    Joined:
    Dec 29, 2009

Share This Page