is it possible to browse files from my iphone application placed at any location in the device?

StackOverflow https://stackoverflow.com/questions/20112477

  •  03-08-2022
  •  | 
  •  

I wanted to browse iPhone device for files like text,pdf,images etc. like in android we can browse in memory card to upload or attach files. But for iPhone, i searched a lot but i didn't find any solution to do this.

有帮助吗?

解决方案

For regular device, the answer is NO.

Every app in iOS runs on its sandbox environment. Your app can't see any data placed outside of the sandbox.

For security reasons, iOS places each app (including its preferences and data) in a sandbox at install time. A sandbox is a set of fine-grained controls that limit the app’s access to files, preferences, network resources, hardware, and so on. As part of the sandboxing process, the system installs each app in its own sandbox directory, which acts as the home for the app and its data.

For jailbroken device, it will break the snadbox environment. So it may be possible to access any files in your device.

其他提示

       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..  

To pick image use 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];
}

To pick files and pdf, use FileManager

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

Yes, it is possible but it uses private API's. Your app will be rejected if you use this and submit to the app store. Check this opensource lib FileSystem

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top