Do it:
NSString *bundleRootpath = [[NSBundle mainBundle] bundlePath]; NSString *filePath = [bundleRootpath pathForResource:@"bags_1" ofType:@"png" inDirectory:@"Images/bagold"] NSFileManager *fileMangr = [NSFileManager defaultManager]; NSArray *dirContents = [fileMangr contentsOfDirectoryAtPath:bundleRootpath error:nil];
JPG filter, if any
NSArray *onlyJPGs; if([dirContents count] > 0){ NSPredicate *fltrJPG = [NSPredicate predicateWithFormat:@"self ENDSWITH '.jpg'"]; onlyJPGs = [dirContents filteredArrayUsingPredicate:fltrJPG]; }
Now PNG, if any
NSArray *onlyPNGs; if([dirContents count] > 0){ NSPredicate *fltrPNG = [NSPredicate predicateWithFormat:@"self ENDSWITH '.png'"]; onlyPNGs = [dirContents filteredArrayUsingPredicate:fltrPNG];
Search for any other format, if any
Merge only JPG and onlyPNG into one array
source share