[CoreData] Undo of insert - how to close the removed object's window?
[CoreData] Undo of insert - how to close the removed object's window?
- Subject: [CoreData] Undo of insert - how to close the removed object's window?
- From: Kaspar Fischer <email@hidden>
- Date: Tue, 15 Nov 2005 10:43:49 +0100
Hi all,
My CoreData document maintains a list of books (the
list is an attribute called "books") and each book may
have an associated window (displaying the book's details).
Now if I add a book, open its window, and perform undo,
I want (i) the book to be removed again (CoreData does
this automatically for me) and (ii) to have the window
closed.
I implemented this by observing the "books" attribute
of my "project" entity: whenever the "books" set changes,
I observe this and step through all windows, closing the
ones that have been removed.
This has one problem: although I remove the window,
it and its subviews are not immediately released (I guess
they are only autoreleased and will be deallocated at
the end of the event loop). As a conequence, my subviews
-dealloc methods are not called, and as these unbind
several bindings, I end up with a closed window that
still has active bindings in some subviews.
The result is that CoreData sends change notifications
to the controllers of these bindings -- and this of course
results in a crash because the bindings are still here,
but the book has already been removed!
I think this is a general pattern, and I would like
to ask if anybody has a solution for it? The pattern is:
in a model, some objects may have an associated window;
how can I make sure that the window gets closed if the
objects are removed due to undo/redo?
Very curious for solutions,
Kaspar
_______________________________________________
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