Bindings and commit/rollback
Bindings and commit/rollback
- Subject: Bindings and commit/rollback
- From: Tomáš Znamenáček <email@hidden>
- Date: Sat, 29 Oct 2005 17:16:06 +0200
Hello,
I am working on a small application that uses bindings. I have got a
dialog that is used to create or edit and object, the dialog uses
bindings and I would like to implement the traditional Save/Cancel
behaviour similar to the database commit/rollback concept. How do I do
that? I tried two approaches, but I don't like neither:
1) Working on a separate object, replacing the original object on commit.
When the dialog starts, I create a duplicate of the object being
edited and I bind the duplicate to the dialog. If the dialog is
cancelled, I simply discard the duplicate, otherwise I discard the
original object and substitute it with the duplicate.
I do not like this solution, because it requires creating a copy of
the object being edited. The object could potentially hold a lot of
data and I do not want to copy megabytes of memory because the user
wants to change a single string.
2) Undo manager.
When the dialog starts, I start an undo group. When the dialog gets
cancelled, I undo the group. This is quite simple, but I hate adding
undo manager code to my class just because of the GUI. Couldn't my
controller do the work for me? How?
What I want is a solution that will not require changes to the code of
the object being edited. All comments are welcome. I am new to
programming so please don't shout if I've missed some obvious solution
:)
T.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden