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 7831965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:57:59+00:00 2026-06-02T11:57:59+00:00

This is a weird one, but I think I’m just missing something simple. I

  • 0

This is a weird one, but I think I’m just missing something simple.

I have an Objective C class called Theme.
Themes load all the art for my game from files and stores them in a NSMutableArray.

When the app launches it reates a new Theme object.
Part of the loading process does something like this:

UIImage *image = [self mergeImage: bg toImage: overlay];
[imageArray addObject: image];

I take a background image and place the overlay on top of it, creating a new UIImage, by using this code:

- (UIImage *)mergeImage:(UIImage *)image1 toImage:(UIImage *)image2 { 
UIGraphicsBeginImageContext(image1.size);  

[image1 drawInRect:CGRectMake(0, 0, image1.size.width, image1.size.height)];  

[image2 drawInRect:CGRectMake(0, 0, image2.size.width, image2.size.height)];  

UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();  
//[resultingImage retain];

UIGraphicsEndImageContext();  

return resultingImage;
} 

All of this happens in the init function of Theme.
Here’s the problem, when I call [[Theme alloc] init] from

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

The app crashes a second later, leaving me with no stack or anything(I figure it screws up some memory and crashes later when it uses it again or something).

Here’s the weird part. If I don’t add the newly merged image to the imageArray, it never crashes. I don’t have the image anymore, but there’s no crash. Also, if I don’t add the image to the array, but I retain it in the mergeImage function, it does crash, which makes me think that retaining this newly-made image is causing the problem.
Weirder still, if I don’t call mergeImage until later on in the app, outside of teh [Theme init] and didFinishLaunchingWithOptions, it’s OK.

Any idea why? What’s wrong with retaining this image when the app first launches?

  • 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-06-02T11:58:01+00:00Added an answer on June 2, 2026 at 11:58 am

    Try this Below Code:

    UIGraphicsBeginImageContext(drawImage.bounds.size); 
    [drawImage.layer renderInContext:UIGraphicsGetCurrentContext()]; 
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); 
    UIGraphicsEndImageContext();
    return viewImage
    

    Thanks..!

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

Sidebar

Related Questions

I am experiencing something weird and have a workaround already, but I don't think
I think this scenario should be weird one but i am stuck up with
This is a weird one, but hopefully someone can give me an idea here.
Ok, this is a really weird one. I have an MPI program, where each
I know this one is the weirdest of all weird questions I have asked
This one is weird. I have a list view that is a part of
Now this is a weird one We have a project where we are reading
I have what I think is a weird error but of course i'm relatively
I thought I understood ViewState, but this is a bit of a weird one.
I'm having this problem: I have two Google maps in one page, showing just

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.