How can I save an image to the camera roll?

user1470914 picture user1470914 · Jun 21, 2012 · Viewed 85.8k times · Source

I am new to Xcode (using 4.3) and am not sure how to save an image to the device's camera roll. All that I have done so far is set up an IBAction for the button to save the image. What library method or function can I use to save an image to the user's camera roll?

Answer

pasawaya picture pasawaya · Jun 21, 2012

You use the UIImageWriteToSavedPhotosAlbum() function.

//Let's say the image you want to save is in a UIImage called "imageToBeSaved"
UIImageWriteToSavedPhotosAlbum(imageToBeSaved, nil, nil, nil);

Edit:

//ViewController.m
- (IBAction)onClickSavePhoto:(id)sender{

    UIImageWriteToSavedPhotosAlbum(imageToBeSaved, nil, nil, nil);
}