是否可以浏览放置在设备中任何位置的iphone应用程序中的文件?

时间:2013-11-21 04:27:49

标签: ios iphone nsfilemanager

我想浏览iPhone设备上的文件,如文本,pdf,图像等,如在android中我们可以浏览存储卡上传或附加文件。但对于iPhone,我搜索了很多,但我没有找到任何解决方案来做到这一点。

4 个答案:

答案 0 :(得分:3)

对于常规设备,答案是否定的。

iOS中的每个应用都在其sandbox environment上运行。您的应用无法在沙盒外看到任何数据。

  

出于安全原因,iOS会在安装时将每个应用程序(包括其首选项和数据)放在沙箱中。沙箱是一组细粒度控件,用于限制应用程序对文件,首选项,网络资源,硬件等的访问。作为沙盒过程的一部分,系统会将每个应用程序安装在自己的沙箱目录中,该目录充当应用程序及其数据的主页。

对于越狱设备,它将打破snadbox环境。因此,可以访问设备中的任何文件。

答案 1 :(得分:3)

       Never do that becose  your app will be rejected,
       if you do like that and upload your app on App Store..... 
       Never use jailbreak in your app friend..  

答案 2 :(得分:0)

选择图像使用UIImagePicker

UIImagePickerController*    imagePicker = [[UIImagePickerController alloc] init];

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
    imagePicker.sourceType      =   UIImagePickerControllerSourceTypePhotoLibrary;
    imagePicker.mediaTypes      =   [UIImagePickerController availableMediaTypesForSourceType:imagePicker.sourceType];
    imagePicker.delegate        =   self;
    imagePicker.editing         =   YES;
    imagePicker.allowsEditing   =   YES;
    [self presentViewController:imagePicker animated:YES completion:nil];
}

要选择文件和pdf,请使用FileManager

NSFileManager *manager = [NSFileManager defaultManager];
NSArray *fileList = [manager directoryContentsAtPath:@"/MYFOLDER"];
NSArray *pdfList = [list filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF ENDSWITH '.pdf'"]];
NSLog(@"%@", pdfList);

答案 3 :(得分:0)

是的,这是可能的,但它使用私有API。如果您使用此应用并提交到应用商店,您的应用将被拒绝。 检查此opensource lib FileSystem

相关问题