When the user presses the Save button, we start the busy mode. Then, if the video camera is running, we prepare to save the next frame. Otherwise, we immediately save the processed version of the static image. Here is the event handler:
- (IBAction)onSaveButtonPressed { [self startBusyMode]; if (self.videoCamera.running) { self.saveNextFrame = YES; } else { [self saveImage:self.imageView.image]; } }
A helper method, saveImage:
, is responsible for the transactions with the filesystem and Photos library. First, we try to write a PNG file to the application's temporary directory. Then, we try to create an asset in the Photos library based on this file. As part of this process, the file is automatically copied. We call other helper methods to show an alert dialog, which will describe the success or failure of the transaction. Here is the method's implementation:
- (void)saveImage:(UIImage *)image { // Try to save the image to a temporary...