0

For a little program that i'm developing, i need to find the list of images and photos inside the device, in this case iPhone Simulator (i saved some images taken from internet). I now that in Android is present the "Cursor" inside the "android.database" API. Is there something similar in Objective C ? I found interesting this tutorial: How I get all the images from a perticular folder(iPhone)? , but in this case the user pass manually the path. In my case i don't know the path where are the images, so i need to use something that search automatically inside the paths. I also saw that for this problem, the AssetsLibrary framework can help, but i'm new on Objective C programming and i'm not sure if it is what i need.

Thanks for each help.

Community
  • 1
  • 1
Hieicker
  • 595
  • 1
  • 11
  • 29
  • see this link http://stackoverflow.com/questions/14531912/storing-images-locally-on-an-ios-device – Deepesh Aug 23 '13 at 07:51
  • If you need to access photos from the device, you must use AssetsLibrary. The sandbox doesn't allow you to access anything outside the app's folder, thus there's no such thing as "the path to a folder that contains all photos on the device" - since the app cannot see that folder anyway. – Khanh Nguyen Aug 23 '13 at 07:55
  • I need to access to the informations of the photos that are in the device. The photos done for example with the fotocamera or dowloaded from internet. I need to find their path, name, width and height. I have only to read these informations. – Hieicker Aug 23 '13 at 07:57

2 Answers2

1

Assuming you are interested in photos which are managed by the iOS Photos application the AssetsLibrary framework would be the way to go.

In particular ALAssetsLibrary should be a good starting point to see if it does what you want to do.

Apple often includes references to sample projects in class references which you can use to see that class in action, such as the MyImagePicker project in this case.

Seán Labastille
  • 712
  • 7
  • 17
  • Thanks for the informations. I will see better ALAssetsLibrary and the MyImagePicker. I need to find some goods tutorials about it. Now i search... – Hieicker Aug 23 '13 at 07:55
1

I used this framework myself and it proves to be very helpful. Using the AssetsLibrary framework, you can get the referenceURL from the info dictionary and fetch the asset. Something like this:

NSURL *assetURL = [info objectForKey:UIImagePickerControllerReferenceURL];

__block NSString *fileName = nil;

ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library assetForURL:assetURL resultBlock:^(ALAsset *asset)  
{
    fileName = asset.defaultRepresentation.fileName;
} 
failureBlock:nil];
anky_believeMe
  • 484
  • 1
  • 4
  • 14
  • Thanks believe_anky, does it search automatically in the paths in the device? I'm trying now to use it. I have declared the ALAssetLibrary and i'm trying to enumerate it using enumerateGroupsWithTypes. – Hieicker Aug 23 '13 at 10:01
  • Yes, it will automatically open up the folders in your gallery. – anky_believeMe Aug 23 '13 at 10:15