1

I am using this code:

UIImageWriteToSavedPhotosAlbum(_curView.image, self,@selector(image:didFinishSavingWithError:contextInfo:), nil);

to save the images to the album. Whenever my device's memory is full, I am using this selector:

-(void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo

but it didn't identify the error, in fact, error is nil. When the error occurs my device's memory is full.

How can I detect if the memory is available or not?

HiDeo
  • 9,900
  • 8
  • 40
  • 43
beautifularea
  • 27
  • 2
  • 7
  • Refer [http://stackoverflow.com/questions/5712527/how-to-detect-total-available-free-disk-space-on-the-iphone-ipad-device](http://stackoverflow.com/questions/5712527/how-to-detect-total-available-free-disk-space-on-the-iphone-ipad-device) – Ketan Parmar Aug 03 '16 at 06:15

3 Answers3

0

If you edit the scheme you want to turn on zombies for (in the "Product" menu, select "Edit Scheme"), go to the "The app.app" stage in the left panel, and the "Arguments" tab on the right. You can then add NSZombieEnabled to the "Environment Variables" section and set the value to YES, as you could in Xcode 3.

In Xcode 4.1 and above, there's also checkbox on the "Diagnostics" tab of the "Run" stage to "Enable Zombie Objects".

gurmandeep
  • 1,166
  • 1
  • 11
  • 28
0

You can try this, use callback method to track any error while saving the image into the album.

(void)processImage:(UIImage *)image {
    [image retain];
    UIImageWriteToSavedPhotosAlbum(reconstructedImage, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
}

(void)image:(UIImage *) image didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo {
    NSLog(@"SAVE IMAGE COMPLETE");
    if(error != nil) {
        NSLog(@"ERROR SAVING:%@",[error localizedDescription]);
    }
}
Mark
  • 3,180
  • 2
  • 33
  • 50
MrWaqasAhmed
  • 1,501
  • 12
  • 12
0

I got the same issue. It seems that you cannot save the image directly from your UIImageView. You need to take a snapshot and save it instead. Swift 3 example:

func takeSnapshot() -> UIImage? {
    UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, false, UIScreen.main.scale);

    imageView.drawHierarchy(in: imageView.bounds, afterScreenUpdates: true)
    let image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}
Lawliet
  • 3,212
  • 1
  • 14
  • 25