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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:11:20+00:00 2026-05-30T14:11:20+00:00

I have some code where I implemented undo functionality, the undo function is as

  • 0

I have some code where I implemented undo functionality, the undo function is as follows:

- (void) undo
{
    drawImage.image = pathArray.lastObject;
    [pathArray removeLastObject];
}

Then I have one more function to capture the current image from the screen; in this function I am getting EXC_Bad_ACCESS error on this

[pathArray removeLastObjectatIndex:0];

No other calls of functions are made in this part of program. Maybe there could be a problem of moving whole array, but I don’t want to use undo manager.

Is there any better way, to get the last object of an array and then remove the first one and move whole array by one?

Notice : path array is MutableArray *patharray;

Thanks all!=)

I just don’t have and idea how to solve this. I didn’t find any solution in the official docs.

  • 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-30T14:11:21+00:00Added an answer on May 30, 2026 at 2:11 pm

    Ultimately, this program would not likely be reachable — It implies there is nothing to ‘undo’ in many contexts, and the option should not be given. Your problem often ultimately lies upstream.

    If that is not quite the case here, here is one approach:

    - (void)undo
    {
       if (0 == self.pathArray.count) {
         self.drawImage.image = nil;
         return;
       }
    
       self.drawImage.image = self.pathArray.lastObject;
       [self.pathArray removeLastObject];
    }
    

    As well, [pathArray removeLastObjectatIndex:]; is not a real selector.

    Update

    See my answer here to enable and find zombies, and locate the reference count offset quickly. Your program should never message a zombie.

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

Sidebar

Related Questions

I have some .NET remoting code where a factory method, implemented in some server
I have some code like this: If key.Equals(search, StringComparison.OrdinalIgnoreCase) Then DoSomething() End If I
I have some code that gives a user id to a utility that then
I have some parallel code (implemented using MPI) that needs to be documented. I'd
I have some old C# plugin code that was implemented strictly with Reflection. In
I have implemented some code that will automatically set a UIScrollView's ContentOffset when the
I have some code implemented in my myDocument.m file that simply attempts to load
I have some data-crunching code implemented in ActionScript, and I'd like to call it
I think I have implemented some of my code wrong. I cannot figure out
I have some code that uses the shared gateway pattern to implement an inversion

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.