3

I've got undo/redo set up in my iphone app, and now I'm looking at saving state, so when the user exits the app and then starts it up again, everything is in the same state, including the undo/redo stack. I don't see any obvious way to serialize the NSUndoManager. Is there a good way to accomplish this?

4

1 回答 1

3

不幸的是,股票 NSUndoManager 不提供对其内部状态的访问。最好的选择是编写自己的替代撤消管理器,或者使用像Graham Cox 的 GCUndoManager这样的开源实现。您将获得源代码级别的访问权限,并且添加 NSCoding 支持相当简单。

或者,您可以尝试继承 NSUndoManager 以维护您自己的独立、可序列化的撤消堆栈,除了它的正常数据库。

于 2010-07-24T15:52:25.507 回答