Undo/Redo for drawing in iOS

I have found a solution for this, we need to create a array of array of DrawingPaths: – (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { // Do the above code, then [m_undoArray addObject:self.currentPath]; } – (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [m_parentUndoArray addObject:[NSArray arrayWithArray:m_undoArray]]; } and then stroke the path in DrawRect.