Get file names of images that are included in project

早过忘川 提交于 2019-12-12 20:19:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!