2

In my app I have a class inherited from UITextView and I need to create and destroy many instances of this view on screen. So my question - is there a way to save (before destroy) and then restore (after create) undo/redo stacks of each instance?

// After creation should be restoring like this.
// (This doesn't work certainly as undoManager is a readonly property)
self.undoManager = storedUndoManager;
Don't Panic
  • 41,125
  • 10
  • 61
  • 80
BorisR
  • 514
  • 1
  • 4
  • 19
  • I guess you could add them to an array or dictionary, and them access that way? – JomanJi Dec 09 '15 at 12:07
  • Thanks, @JomanJi. But what will exact restoring process be? How can I manipulate `undoManager` property of UITextView? – BorisR Dec 09 '15 at 12:18
  • I would recommend creating a NSMutableDictionary property, and storing each `undoManager` with the key `tag` of the UITextView. Then, when you need to access it later on, you can request the `tag` from the dictionary to get the appropriate `undoManager` – JomanJi Dec 10 '15 at 22:17

0 Answers0