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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:12:40+00:00 2026-06-01T18:12:40+00:00

I have noob objective-c question. How do you add an UIImage to a MSMutableArray?

  • 0

I have noob objective-c question. How do you add an UIImage to a MSMutableArray? Here is the code that I have:

MSMutableArray *arr = [[NSMutableArray alloc] init];
UIImage *image;
UIGraphicsBeginImageContext(contextSize);
{
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextTranslateCTM(context, 0, pushUpSize);

    [screenWindow.layer renderInContext: context];  
    image = UIGraphicsGetImageFromCurrentImageContext();
}
UIGraphicsEndImageContext();
[arr addObject:image];

But this crashes the program when it tries to add the image. I read somewhere that its adding a variable but not the pointer, is that correct? How do I add the UIImage to the array, its an object isn’t it?

Thanks!

  • 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-01T18:12:41+00:00Added an answer on June 1, 2026 at 6:12 pm

    @thiesdiggity: Not much is wrong in your code from what I can see. But just try out the below code as I think the image object is nil:

    MSMutableArray *arr = [[NSMutableArray alloc] init];
    UIImage *image;
    UIGraphicsBeginImageContext(contextSize);
    {
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextTranslateCTM(context, 0, pushUpSize);
    
        [screenWindow.layer renderInContext: context];  
        image = UIGraphicsGetImageFromCurrentImageContext();
    }
    UIGraphicsEndImageContext();
    
    if(image != nil)
    {
        [arr addObject:image];
    }
    

    Let me know if you need more help and please post your crash log for more help

    Hope this helps.

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

Sidebar

Related Questions

Noob question here! I have an array with hashes that looks like this: arr
a noob question here. I have an app that does number calculations. I support
a noob question here. I have the following code: - (IBAction)selectExistingPicture { if ([UIImagePickerController
a noob question here. I have a very strange situation that's very puzzling to
I have a noob question =P How can I programatically add a canvas to
I have a noob question here. I'm getting my head around the C++ structure
i have a noob question. I have a record in a table that looks
noob question here. I have a has_many :through relationship between items and tags. Finding
I'm learning Objective-C, noob question. I'm working on a project in Xcode that requires
Rails noob here. I have a rails application with (in this example) three tables.

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.