views:

155

answers:

1

Hi all,

I have a tableview with custom cells. The cell shows photos which I'm getting in the form of url from an xml which I'm loading in webviews. There might be any number of photos, but I'm showing only first three photos in normal cell view.

When user taps the cell, I want to insert all the photos that are in the form of urls for that indexPath into photo library and display them just like the facebook app.

Can anybody please tell me:

  1. How to insert photos into photo library at runtime that are in the form of urls?

  2. Shall I erase the previous photos all the time I'm inserting the new ones?

Thanx in advance.

A: 

You'll need to download the image with NSURLConnection and in your delegate methods save the downloaded data (in connection:didReceiveData:) in downloadData. Then in connectionDidFinishLoading: create a UIImage out of it with:

image = [[[UIImage alloc] initWithData:downloadData] autorelease];

then to insert the photo into the photo library:

UIImageWriteToSavedPhotosAlbum(image);

I don't think you're allowed to erase images from the Photo Library.

lucius