2

I'm writing an iPhone application. I'm wondering if I can get a list of files/filenames of the photos stored in the iPhone library (or those in the simulator).

Essentially, I'm asking if I can get the filenames of the photos stored on the iPhone or simulator.

I appreciate any help, thanks!

EDIT:

image = [UIImage imageNamed:@"/Users/Library/Application Support/iPhone Simulator/5.0/Media/DCIM/100APPLE/IMG_0002.jpg"];
imageView.image = image;

doesn't work, unfortunately.

Objc55
  • 156
  • 1
  • 5
  • 18

3 Answers3

9

You simply have to use the UIImagePickerController.

It gives something like that:

-(IBAction) getPhoto:(id) sender {
    UIImagePickerController * picker = [[UIImagePickerController alloc] init];

    // Don't forget to add UIImagePickerControllerDelegate in your .h
    picker.delegate = self;

    if((UIButton *) sender == choosePhotoBtn) {
        picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
    } else {
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    }

    [self presentModalViewController:picker animated:YES];
}
Vinestro
  • 1,072
  • 1
  • 10
  • 32
3

This is something of a duplicate of a SO question asked already here - Get list of all photo albums and thumbnails for each album

From that answer: Take a look at AssetsLibrary framework.

Note that if you have access to the iOS 6 Beta, you'll want to note the changes taking place for accessing those assets. Can say no more per NDA.

Community
  • 1
  • 1
Matt S.
  • 1,882
  • 13
  • 17
  • Sorry -- how can I do it without using that framework? I just need a filename/path. Thanks! – Objc55 Jul 05 '12 at 21:35
  • 2
    Just seeing this - you don't have access to the filename/path unless on a jailbroken device. This is per the sandboxing security of all apps. – Matt S. Aug 06 '12 at 11:02
-3

Using this methods, you can easily implement that.

https://www.dropbox.com/sh/trmg44a93hwq35x/AACAVGY6VKEDR0tDUOqoxd-Ba?dl=0

Ibrar Ahmed
  • 1,039
  • 1
  • 13
  • 25
Chigs79
  • 162
  • 4