Objective c 如何将Images从mainBundle中的文件夹提取到阵列?

Objective c 如何将Images从mainBundle中的文件夹提取到阵列?,objective-c,xcode,directory,mainbundle,Objective C,Xcode,Directory,Mainbundle,在我的应用程序包中,我有几个项目的图像 ItemA_largepicture.png ItemA_smallPicture.png ItemA_overViewPicture.png ItemB_largepicture.png ItemB_smallPicture.png ItemB_overViewPicture.png ItemC_largepicture.png ItemC_smallPicture.png ItemC_overViewPicture.png 例如,我想将所有ItemB

在我的应用程序包中,我有几个项目的图像

ItemA_largepicture.png

ItemA_smallPicture.png

ItemA_overViewPicture.png

ItemB_largepicture.png

ItemB_smallPicture.png

ItemB_overViewPicture.png

ItemC_largepicture.png

ItemC_smallPicture.png

ItemC_overViewPicture.png

例如,我想将所有ItemB图片提取到一个数组中。我可以照王子的建议去做

NSString *bundleRootPath = [[NSBundle mainBundle] bundlePath];
NSArray *bundleRootContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:bundleRootPath error:nil];
NSArray *files = [bundleRootContents filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self beginswith 'ItemB'"]];
NSLog(@"%@",files);
这很有效。下一个问题是,所有ItemB文件都位于名为ItemB的文件夹中。不知何故,我需要在bundle中为ItemB文件夹添加一个路径。我想

NSString *bundleRootPath = [[NSBundle bundleWithPath:@"ItemB"] bundlePath];
这是合乎逻辑的,但不起作用。 有人能解释一下这是如何工作的,以及如何访问文件夹吗

NSString *bundleRootPath = [[NSBundle mainBundle] bundlePath];
NSString *itemBPath = [bundleRootPath stringByAppendingPathComponent:@"ItemB"];
NSArray *itemBContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:itemBPath error:nil];