0

i am downloading an image from the internet but saving it on the desktop.I want to save it in photo gallery of the iphone. How is this possible?

my code is here:

NSString *docDir = @"/Users/gaurav/Desktop";
NSString *pngFilePath = [NSString stringWithFormat:@"%@/neetu%d.png",docDir , r];
r++;

//NSString *pngFilePath = [NSString stringWithFormat:@"%@/flower.png",docDir];
NSData *data1 = [NSData dataWithData:UIImagePNGRepresentation(image)];
[data1 writeToFile:pngFilePath atomically:YES];
bruno
  • 1,830
  • 2
  • 22
  • 36
user642472
  • 61
  • 1
  • 3

2 Answers2

1

You can use this function:

UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo);

You only need completionTarget, completionSelector and contextInfo if you want to be notified when the image is done saving, otherwise you can pass in nil.

PgmFreek
  • 6,374
  • 3
  • 36
  • 47
0

Look into UIImageWriteToSavedPhotosAlbum

UIImageWriteToSavedPhotosAlbum working... sometimes

Community
  • 1
  • 1
Stefan H
  • 6,635
  • 4
  • 24
  • 35