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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:27:21+00:00 2026-06-12T06:27:21+00:00

// This is the line which retrieves the current image on the UIView CGImageRef

  • 0
// This is the line which retrieves the current image on the UIView
CGImageRef originalImage = imageView.image.CGImage;

I declare this in a method I use to edit my image which can be called by several buttons.

Is there anyway I can declare this variable globally so it always holds the first image loaded in the UIView? I can then use a copy variable to do all the editing on e.g.

CGImageRef copyImage = originalImage;

I have tried to make it global by declaring it in the header file and instantiate it in the method file however when I try and access the global variable in another method it is as if it hasn’t been made global.

Any advice or better solutions would be greatly appreciated.

  • 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-12T06:27:23+00:00Added an answer on June 12, 2026 at 6:27 am

    It is not entirely clear what you are trying to do, but what I would point out is:

    1. the assignment

                CGImageRef copyImage = originalImage;
      

      will not create a copy of your image; it will simply give you a local variable pointing to the same image as originalImage; if you modify copyImage, you also modify originalImage;

    2. if you want to make a copy of an CGImage so that you can modify it freely while keeping the original safe, use:

            CGImageRef img1 = CGImageCreateCopy(img2);
      
    3. if you want to save your original image as under point 2, simply add a property to your class and initialize it soon after you have got your CGImage in place (e.g., in viewDidLoad:

             -(void) viewDidLoad {
                 ...
                 self.originalImage = CGImageCreateCopy(imageView.image.CGImage);
                 ...
             }
      

    self.originalImage will be your original image, while you will be able to freely modify imageView.image.CGImage.

    Don’t forget to release the copied image in your dealloc method.

    Hope this helps.

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

Sidebar

Related Questions

here is my current line of code: $(<li>).text($(this).text()).appendTo(#theList); Which results in <ul id=theList> <li>blah</li>
The first statement which uses this ( line 2 ) errors with: this is
In my web app I have a line which looks like this: small textbox
I just recently found myself writing this line of code, which i did not
I found the code from the net in which i cant understand this line:-
I have created a reddot cms component, in which I added this line Also,
This is my code in which every line is giving me an invalid context
I have this query which on executing in my sql command line client executes
I have this common issue of 'new line' in php-csv which is making me
I have a line, which is a sprite made by using this code CGPoint

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.