Question

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.

Was it helpful?

Solution

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];

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top