如何从我的iPhone App文档目录中选择所有图像 [英] How to select all the images from my iPhone App document directory

查看:110
本文介绍了如何从我的iPhone App文档目录中选择所有图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含一堆图像的文件夹.我想将所有图像的名称添加到数组中.图像位于应用程序上我文档的文件夹中.参见屏幕截图.

I have a folder containing a bunch of images. I would like to add the names of all the images to an array. The images are in a folder in my document on the app. See screen shot.

我知道,如果我想获得其中一张图像,我将使用以下代码.

I know If I would like to get one of these images I would use the following code.

NSArray   *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString  *documentsDirectory = [paths objectAtIndex:0];
NSString  *filePath = [NSString stringWithFormat:@"%@/POIs/%@", documentsDirectory,image];

是否可以选择文件夹中的所有文件?如果可以的话,是否还可以选择文件名并将它们添加到数组中?

Is it posible to select all the files in the folder? If it is would it also be possible to select the names of the files and add them to an array?

谢谢

推荐答案

获取POS文件夹的文件路径:

Get the file path of the POS folder:

NSString  *filePath = [NSString stringWithFormat:@"%@/POIs", documentsDirectory];

然后执行:

NSArray *files = [fileManager contentsOfDirectoryAtPath:filePath 
                                                  error:nil];

代码未经测试

这篇关于如何从我的iPhone App文档目录中选择所有图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆