I am building an iPhone app with Objective C. In my app, I am drawing the strokes on image and want to implement the undo and redo functionalities.
I have used NSUndoManager
for this. With this I am able to undo my drawing at one level down, but my requirement is to undo the drawing at its lowest possible level (or at least minimum 10 level down). I had already set the setLevelsOfUndo
to 10 but it does not work.
I'm using the following code:
- (void)UnDoImage1:(UIImage*)image
{
if (capturedImage.image != image)
{
[self.managedObjectContext.undoManager undo];
[[self.managedObjectContext.undoManager prepareWithInvocationTarget:self] UnDoImage1:capturedImage.image];
[capturedImage release];
capturedImage.image = [image retain];
}
}
Please let me know where I am incorrect. I have already Googled for this for a long time but did not find the exact cause of failure of the functionality.