Help: List contents of iPhone application bundle subpath?
<p>I am trying to get a listing of the directories contained within a subpath of my application bundle.  I've done some searching and this is what I have come up with</p>

<pre><code>- (void) contents {
 NSArray *contents = [[NSBundle mainBundle] pathsForResourcesOfType:nil
                                               inDirectory:@"DataDir"];
 if (contents = nil) {
  NSLog(@"Failed: path doesn't exist or error!");
 } else {
     NSString *bundlePathName = [[NSBundle mainBundle] bundlePath];
  NSString *dataPathName = [bundlePathName stringByAppendingPathComponent:
                                 @"DataDir"];
     NSFileManager *fileManager = [NSFileManager defaultManager];

     NSMutableArray *directories = [[NSMutableArray alloc] init];
     for (NSString *entityName in contents) {
            NSString *fullEntityName = [dataPathName
                                       stringByAppendingPathComponent:entityName];
            NSLog(@"entity = %@", fullEntityName);
            BOOL isDir = NO;
            [fileManager fileExistsAtPath:fullEntityName isDirectory:(&amp;isDir)];
            if (isDir) {
                [directories addObject:fullEntityName];
                NSLog(@" is a directory");
            } else {
                NSLog(@" is not a directory");
            }
        }
        NSLog(@"Directories = %@", directories);

        [directories release];
 }
}
</code></pre>

<p>As you can see I am trying to get a listing of directories in the app bundle's DataDir subpath.  The problem is that I get no strings in my contents NSArray.</p>

<p>note:<br>
- I am using the simulator<br>
- When I manually look in the .app file I can see DataDir and the contents therein<br>
- The contents of DataDir are png files and directories that contain png files<br>
- The application logic needs to discover the contents of DataDir at runtime<br>
- I have also tried using  </p>

<pre><code> NSArray *contents = [fileManager contentsOfDirectoryAtPath:DataDirPathName error:nil];
</code></pre>

<p>and I still get no entries in my contents array</p>

<p>Any suggestions/alternative approaches?</p>

<p>Thanks. </p>
