user642472
user642472

Reputation: 61

saving image from web in simulator photo gallery

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

Upvotes: 0

Views: 436

Answers (2)

PgmFreek
PgmFreek

Reputation: 6402

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.

Upvotes: 1

Stefan H
Stefan H

Reputation: 6683

Look into UIImageWriteToSavedPhotosAlbum

UIImageWriteToSavedPhotosAlbum working... sometimes

Upvotes: 0

Related Questions