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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:28:48+00:00 2026-06-05T03:28:48+00:00

I am new to the CGContext world. I need to create a stack of

  • 0

I am new to the CGContext world.
I need to create a stack of CGContext(s) in a NSMutableArray.

  1. I have a valid PDFContext created with UIGraphicsBeginPDFContextToData

  2. I’m passing this context to a method as an argument

    -(void) drawTo:(CGContextRef) context{}

  3. First I identify the current context with:

    CGContextRef curCon = context;

  4. NSLog value:

    context:<CGContext 0x6b79d60>

  5. Then I attempt to make a copy of the current context:

    CGContextRef conCopy = UIGraphicsGetCurrentContext();

  6. Then I add it to my NSMutableArray:

    [myMutableArray* addObject:(id)conCopy];

  7. Then I list the content of the NSMutableArray:

    after an object added:<__NSArrayM 0x6b7e850>(<CGContext 0x6b79d60>)

And I see that the added value is the same context as originally sent to this method as an argument and not the copy.

What am I missing here ? Or perhaps it’s not possible to store the status of current context in a NSMutableArray ? I understand that paths would not get saved, that’s fine. I need to save anything and everything about the current context that can be saved.
Thank you!

  • 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-05T03:28:52+00:00Added an answer on June 5, 2026 at 3:28 am

    You can’t do this directly. But what’s the real problem you’re trying to solve? CGContextSaveGState() does what you’re asking for, but only within the scope of the current context. CGLayer can effectively create contexts that you can carry around (though you still can’t serialize them).

    If your real goal is to save non-path state in a copyable form, then you can create a copyable object by calling all the CGContextGet... methods and storing their results. Then you can call CGContextSet... on them to make a new context. It’s tedious, but should not be difficult. (Though it does raise the question of why. It feels like a very odd thing to be doing.)

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

Sidebar

Related Questions

So I have this linq query clause. var ctx = new Context(); IQueryable<Users> consulta
Hi I am new to wicket framework, I need to create a context menu
I'm trying to do this: using(var context = new SampleEntities()) { User user =
I have following code: //preparing DAO objects FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(test-context.xml); surveyDao =
Trying to use this code to connect the AD PrincipalContext context = new PrincipalContext(ContextType.Domain,
This statement doesnot work in Entity Framework context.sleep.Where(o=>o.clientDateTime.TimeOfDay>new TimeSpan(18,0,0)).ToList(); Please suggest me a workaround.
For example Intent intent = new Intent(this, SecondActivity.class); eclipse error: The method setClass(Context, Class)
containerBuilder .Register<IGraphClient>(context => { var graphClient = new GraphClient(new Uri(http://localhost:9999/db/data)); graphClient.Connect(); // Particularly this
I need to switch data context for some records. So basically I have db
What I'm trying is this: 1) Create a new manged object 2) Get it's

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.