私のアプリバンドルには、いくつかのアイテムのいくつかの画像があります。
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という名前のフォルダーにあることです。どういうわけか、バンドル内のパスをItemBフォルダーに追加する必要があります。と思った
NSString *bundleRootPath = [[NSBundle bundleWithPath:@"ItemB"] bundlePath];
論理的でしたが、これは機能しませんでした。誰かがこれがどのように機能するか、そしてフォルダにアクセスする方法を説明できますか?