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

  • Home
  • SEARCH
  • 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 7045899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:35:11+00:00 2026-05-28T02:35:11+00:00

I have this code in one of my NSManagedObjects : if (self.tempImageStorage) { return

  • 0

I have this code in one of my NSManagedObjects:

if (self.tempImageStorage) {
    return self.tempImageStorage;
} else if(self.imageData) {
    NSLog(@"%@ %d",self.imageData, self.imageData.length);
    self.tempImageStorage = [UIImage imageWithData:self.imageData];
    return self.tempImageStorage;
}

Occasionally, usually when I’m flipping through the images quickly, it will come back with an EXC_BAD_ACCESS on the 5th line (UIImage imageWithData line), and I can’t po (printobject) self in the console, so I assume that the NSMananagedObject itself has been deallocated. What doesn’t make sense is that it was able to reference self for the 2 ifs, and I even log the image data and its length just fine right before it.

How could the NSManagedObject be deallocated in during that period since this is all happening on the same thread (and it’s the main thread)?

PS: I have Zombies enabled but it still doesn’t let me po self.

Code that sets the image data:

- (void) processRequest:(ASIHTTPRequest *) request
{
    UIImage * orig = [UIImage imageWithData:[request responseData]];
    CGSize targetSize = isPad()?CGSizeMake(446,150):CGSizeMake(320, 108);
    CGRect fourPanelSize = CGRectMake(0, 0, 1000, 336);
    CGImageRef imageRef = CGImageCreateWithImageInRect([orig CGImage], fourPanelSize);
    CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef);
    CGColorSpaceRef colorSpaceInfo = CGImageGetColorSpace(imageRef);

    if (bitmapInfo == kCGImageAlphaNone || bitmapInfo == kCGImageAlphaLast) {
        bitmapInfo = kCGImageAlphaPremultipliedLast;
    }

    CGContextRef bitmap;
    bitmap = CGBitmapContextCreate(NULL, targetSize.width, targetSize.height, CGImageGetBitsPerComponent(imageRef), CGImageGetBytesPerRow(imageRef), colorSpaceInfo, bitmapInfo);    

    CGContextDrawImage(bitmap, CGRectMake(1, 1, targetSize.width-2, targetSize.height-2), imageRef);
    CGImageRef ref = CGBitmapContextCreateImage(bitmap);
    UIImage* newImage = [UIImage imageWithCGImage:ref];

    CGContextRelease(bitmap);
    CGImageRelease(ref);

    NSData * thumbData = UIImagePNGRepresentation(newImage);
    NSData * imageData = UIImagePNGRepresentation(orig);

    //Post notification on main thread since it will be updating the UI
    [[NSOperationQueue mainQueue] addOperationWithBlock:^{
        self.tempImageThumbStorage = newImage;
        self.imageThumbnailData = thumbData;
        self.tempImageStorage = orig;
        self.imageData = imageData;

        [(AppDelegate*)[UIApplication sharedApplication].delegate saveContext];

        NSMutableDictionary * userInfo = [[NSMutableDictionary alloc] initWithCapacity:1];
        [userInfo setObject:[NSNumber numberWithBool:YES] forKey:@"status"];
        [userInfo setObject:self forKey:@"comic"];

        [[NSNotificationCenter defaultCenter] postNotificationName:PCRLoadMediahNotification object:self userInfo:userInfo];
        strongSelf = nil;
    }];

}
  • 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-28T02:35:11+00:00Added an answer on May 28, 2026 at 2:35 am

    Turns out I was saving the context too often which was causing the imageData not to be saved to disk properly, and causing the exception.

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

Sidebar

Related Questions

I've seen second one in another's code and I suppose this length comparison have
I have this code that has one button that let's me choose an entry
I am creating a rails app and have used this code in one of
I have this code to open multiple files one at a time that is
I have this code: s(x => x.Open()); s is a method which calls one
I'm training code problems like UvA and I have this one in which I
I have a piece of code VERY similar to this one http://java.sun.com/developer/onlineTraining/JavaMail/contents.html#JavaMailFetching I the
I usually do not have difficulty to read JavaScript code but for this one
Racking my brains on this one. I have the code below: the first stages
I have this code in one of my @PersistenceCapable classes: @Persistent private Blob data;

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.