Re: Detecting a deleted object
Re: Detecting a deleted object
- Subject: Re: Detecting a deleted object
- From: Chuck Hill <email@hidden>
- Date: Sun, 19 Feb 2006 15:03:42 -0800
On Feb 18, 2006, at 1:26 PM, Miguel Arroz wrote:
Hi!
Imagine the following code (I'm writing this directly on the
email, it's possible that it contains errors):
EOEditingContext myContext = getMyContexy();
MyClass myObject = giveMeSomeObjectOfMyClassSotredOnTheDataStorage
(myContext);
myContext.deleteObject(myObject);
myContext.saveChanges();
Right after this, what exactly is myObject? Is there a way to
know that it references a previously deleted object? The only way I
can find is calling myObject.editingContext() and catch a
NullPointerException, but that method is very very dirty... is
there a better way?
I've always used the object.editingContext() == null test. A better
way might be to have the affected pages / components register for the
EditingContextDidSaveChangesNotification of EOEditingContext or the
ObjectsChangedInStoreNotification of EOObjectStore. The page can
inspect the list of deleted objects and take action if it is
affected. The potential for some interesting race conditions arises
when dispatching requests concurrently.
Chuck
--
Coming in 2006 - an introduction to web applications using WebObjects
and Xcode http://www.global-village.net/wointro
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems. http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden