Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7597699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:13:16+00:00 2026-05-30T22:13:16+00:00

I’m getting this error [Not A Type release]: message sent to deallocated instance on

  • 0

I’m getting this error “[Not A Type release]: message sent to deallocated instance” on the last line of code “CGImageRelease(imageToSave);”. Please explain why and what I need to use to fix it. I’m using ARC, but I don’t think that applies to CG objects. I’ve updated the code with the suggested answers after testing that they work.

CGImageRef imageToSave;
UIImage *uiImageToSave = [[UIImage alloc] init];
if (sender == nil) {
    imageToSave = [originalImage CGImage];
} else {
    uiImageToSave = [self addTitleBlock:annotatedImage];
    imageToSave = [uiImageToSave CGImage];
}
[library writeImageToSavedPhotosAlbum:imageToSave metadata:imageMetadata completionBlock:^(NSURL *assetURL,NSError *error){
    [saveAlertView dismissWithClickedButtonIndex:0 animated:YES]; 
    [activityIndicator stopAnimating];
    [activityIndicator removeFromSuperview];
    if(error == nil) {
        if (sender != nil) {
            [self setToolbarItems:viewingToolbarItems animated:YES];
            [UIView beginAnimations:@"savePhoto" context:NULL]; 
            [UIView setAnimationTransition:PHOTO_SAVE forView:pictureView cache:YES]; 
            [UIView setAnimationDuration:0.5f];
            [UIView setAnimationDelay:0.0f];
            [UIView setAnimationPosition:CGPointMake(45, 430)];
            [splashScreen setHidden:NO];
            [imageView setHidden:YES];
            [sampleImageView setHidden:YES];
            [colorImageView setHidden:YES];
            [UIView commitAnimations];
        } else {
            [saveButton setEnabled:YES];
            [cancelButton setEnabled:YES];
        }
    } else {
          if (sender != nil) {
             saveAlertView=[[UIAlertView alloc] initWithTitle:nil message:@"Image Save Failed!" delegate:self cancelButtonTitle:@"Continue" otherButtonTitles:nil];
         } else {
             saveAlertView=[[UIAlertView alloc] initWithTitle:nil message:@"Original Image Save Failed!" delegate:self cancelButtonTitle:@"Continue" otherButtonTitles:nil];
         }
        [saveAlertView show];
        [saveButton setEnabled:YES];
        [cancelButton setEnabled:YES];
    }
    // CGImageRelease(imageToSave);
}];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:13:17+00:00Added an answer on May 30, 2026 at 10:13 pm

    Even worse than what someone0 is telling you:

    I would say as you defined your uiImageToSave in the else block, the reference you created with imageToSave is not valid outside of the else block – so any use of imageToSave in your code is just working by accident, as long as the memory is not overwritten yet.

    And as said, the [UIImage CGImage] call only gives you a reference to the image data, it does not make a copy or retain it – so you may not release it yourself, it is released automatically when the UIImage ceases to exist – which in your case is just one line after you make the reference.

    UPDATE:

    The code in the original posting is adjusted – the uiImageToSave is now defined in the right place (just if anyone wonders about my comment which is now not really fitting the original posting anymore :-).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
Does anyone know how can I replace this 2 symbol below from the string
I need a function that will clean a strings' special characters. I do NOT
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.