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.
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:
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.