How can we get all file names starting with a prefix from resource folder..
You can achieve that adapting the following code:
NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:
[[NSBundle mainBundle] bundlePath] error:nil];
NSArray *pngs = [files filteredArrayUsingPredicate:
[NSPredicate predicateWithFormat:@"self ENDSWITH[cd] '.png'"]];
NSLog(@"%@", pngs);
Running this code you will see the list of PNG's on your bundle. Change the predicate to match with the prefix you want:
NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:
[[NSBundle mainBundle] bundlePath] error:nil];
NSArray *filesWithSelectedPrefix = [files filteredArrayUsingPredicate:
[NSPredicate predicateWithFormat:@"self BEGINSWITH[cd] 'prefix'"]];
NSLog(@"%@", filesWithSelectedPrefix);
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