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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:43:02+00:00 2026-05-22T23:43:02+00:00

I have a finger painting view that I am implementing undo/redo. All the drawing

  • 0

I have a finger painting view that I am implementing undo/redo. All the drawing occurs on a CGLayer called lineLayer.

As soon as the user touches the screen but before any modification is done to the screen, I need to quickly grab the views content and create an undo level.

Obviously saving the view to disk is not an option, because it takes too long. The solution I imagined is to copy the CGLayer to a dictionary, using something like this:

// I copy the layer as a NSValue
NSValue *layerCopy = [NSValue valueWithBytes:&myLayer objCType:@encode(CGLayerRef)];

I store it on a dictionary

NSString *aKey = [NSString stringWithFormat:@"%d", [number intValue]];
[self.dictUNDO setObject:layerCopy forKey:aKey];

later I retrieve it using

NSString *myKey = [NSString stringWithFormat:@"%d", [number intValue]];
NSValue *myCopy = [self.dictUNDO objectForKey:myKey]; 
[myCopy getValue:&lineLayer];
//lineLayer is the CGLayer where the drawing happens

the problem is that lineLayer is not changed at all by this reading operation.
It continues to have the same contents as before.

Am I missing something?

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-05-22T23:43:03+00:00Added an answer on May 22, 2026 at 11:43 pm

    Have you considered Core data for managing your objects? I’m asking because Undo/redo comes for free with it?

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

Sidebar

Related Questions

I have finger painting stuff on one view of my app. When the user
I have a view with which you can do finger drawing. It's currently in
I'm working on a simple note-taking/painting app. I have a view controller that works
I currently have a class called clientActivity that contains a finger paintig activity that
I have 3 UIGestureRecognizers attached to a view: one finger double tap, two fingers
I have a texture that follows a user's finger in GLKit. I calculate the
I have an ImageView that you can use to do a one-finger pan, or
Basically, I have a ViewFlipper that flips when I swipe my finger on it.
I have an app that I need to test 3 finger touches and 2
I have an object that can be moved across the screen with the finger.

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.