FROM : Keary Suska
DATE : Sun Jan 06 21:54:10 2008
on 1/4/08 9:13 PM, <email_removed> purportedly said:
> This works very well with undo and redo until I delete the object "self".
> In facts when I delete the object and call "Undo Delete Object", I create a
> brand new object using a dictionary with the old object's values. Of course
> the new object has a different pointer, so if I call now "Undo Set On" I get
> a crash. How can I fix this trouble?
>
>
> To avoid this trouble actually I use a complex method which stores into the
> undo record the "index" of the object in the object list. So for example I
> say to undo the 4th object in the list. But I am not sure this method is
> safe and clear. Have you a better idea?
Implement the "reverse" of the delete object, passing the current object to
the undo manager. E.g.:
[undoManager registerUndoWithTarget:self
selector:@selector(undeleteObject:) object:currentObject];
Depending on your context and implementation, you may have to watch out for
memory issues (your objects will not get released until undone or the undo
action is removed). You may also need to consider redo behavior if you
aren't controlling undo entirely by code.
Best,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
DATE : Sun Jan 06 21:54:10 2008
on 1/4/08 9:13 PM, <email_removed> purportedly said:
> This works very well with undo and redo until I delete the object "self".
> In facts when I delete the object and call "Undo Delete Object", I create a
> brand new object using a dictionary with the old object's values. Of course
> the new object has a different pointer, so if I call now "Undo Set On" I get
> a crash. How can I fix this trouble?
>
>
> To avoid this trouble actually I use a complex method which stores into the
> undo record the "index" of the object in the object list. So for example I
> say to undo the 4th object in the list. But I am not sure this method is
> safe and clear. Have you a better idea?
Implement the "reverse" of the delete object, passing the current object to
the undo manager. E.g.:
[undoManager registerUndoWithTarget:self
selector:@selector(undeleteObject:) object:currentObject];
Depending on your context and implementation, you may have to watch out for
memory issues (your objects will not get released until undone or the undo
action is removed). You may also need to consider redo behavior if you
aren't controlling undo entirely by code.
Best,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
| Related mails | Author | Date |
|---|---|---|
| Lorenzo | Jan 5, 05:13 | |
| Keary Suska | Jan 6, 21:54 |






Cocoa mail archive

