问题
I have added many images to my Xcode project: icons, a main background, default (for splash screen), placeholders, and others. Can I get all these images' names into an array?
回答1:
This should return an array of all your pngs in your app folder.
[[NSBundle mainBundle] pathsForResourcesOfType:@"png" inDirectory:nil];
Note* The array contains paths. If you just want the name use - (NSString *)lastPathComponent
on a specific index of that array, i.e.
NSString *imgName = [[imgArray objectAtIndex:0]lastPathComponent]; //myImage.png
来源:https://stackoverflow.com/questions/11993469/get-file-names-of-images-that-are-included-in-project