Reputation: 84
How can I use different Undo Managers for a view?
I want a similar behaviour to Xcode.
For example, in Xcode if you edit multiple files (e.g. Swift files) there is a separate Undo Manager for each edited file.
Upvotes: 0
Views: 333
Reputation: 535202
if you edit multiple files (e.g. Swift files) there is a separate Undo Manager for each edited file.
Sure, because each file is handled thru a different NSDocument instance, and a document has an undoManager instance property. This is actually built in if you just start with the document based application template.
If you are not using documents, you are certainly using NSResponders. Every view is a responder. A responder has an undoManager property. So it’s just a question of how the responder chain is structured.
Upvotes: 1