I'm developing an iPhone and iPad application with latest SDK and XCode 4.2.
I want to retrieve the path for all resources which name start with 001. Their name is 001XXX.jpg (XXX is unknown). I don't know how many resources are.
For example, I will have bundle in app the following files:
001001.jpg
001002.jpg
001003.jpg
I want to get a NSArray with the path for each of this three files.
You can you do it in two steps:
The code (not tested) could look like:
NSArray *files = [[NSBundle mainBundle] pathsForResourcesOfType:@"png" inDirectory:@"."];
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF BEGINSWITH[c] '001'"];
NSArray *images = [files filteredArrayUsingPredicate:pred];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With