iPhone dev: Recurse all project resoureces and collect paths
Posted
by thomax
on Stack Overflow
See other posts from Stack Overflow
or by thomax
Published on 2010-04-27T20:16:55Z
Indexed on
2010/04/27
20:23 UTC
Read the original article
Hit count: 339
I have a bunch of HTML resources in my app organized in a hierarchy like so:
dirA
|---> index.html
|---> a1.html
|---> a2.html
|---> dirB
|---> b1.html
|---> b2.html
|---> dirC
|---> c5.html
|---> c19.html
I'm trying to collect the absolute paths of all HTML resources however deep down, but can't seem to figure out how. So far I've tried:
NSArray myPaths = [[NSBundle mainBundle] pathsForResourcesOfType:@"html" inDirectory:nil];
This returns an empty array, because I have no HTML files at the root of my project. Then there is:
NSArray myPaths = [[NSBundle mainBundle] pathsForResourcesOfType:@"html" inDirectory:@"dirA"];
This returns an array containing only the paths for the three HTML resources directly below dirA. If I read the doc correctly, I guess this is to be expected; pathsForResourcesOfType
does not traverse subdirectories. But is there a (preferably nice) way to do it?
© Stack Overflow or respective owner