且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取项目中包含的图像的文件名

更新时间:2022-06-23 05:29:40

这应该返回应用文件夹中所有 png 的数组.

This should return an array of all your pngs in your app folder.

[[NSBundle mainBundle] pathsForResourcesOfType:@"png" inDirectory:nil];

注意* 该数组包含路径.如果您只想要名称在该数组的特定索引上使用 - (NSString *)lastPathComponent,即

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