iosiphonealasset

Getting the path of an ALAsset


How can I get the path of each item in an array of ALAssets?

I would like to get the images so that I can add them to an email

e.g.

NSString *path = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"png"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[mailViewController addAttachmentData:myData mimeType:@"image/png" fileName:@"sample"];

How can this be done?


Solution

  • Assuming you already have access to an array of ALAsset objects, you can retrieve their URL like this:

    someAsset.defaultRepresentation.url