Re: refreshing and relationships
Re: refreshing and relationships
- Subject: Re: refreshing and relationships
- From: Dev WO <email@hidden>
- Date: Sun, 15 Jan 2006 18:52:49 +0100
Hi Tom,
I think the deleted object is still in there because you have an
NSArray and not a NSMutable one, so even if you delete the object in
the editing context, as long as you are not requesting a new NSArray,
you'll get the "original" array and not an "editing context fresh" one.
I'm not sure, but someone will probably say if I'm wrong, I would
create an NSMutableArray (called mutableTargets for example) and do:
mutableTargets.removeObject(aSpecificTargetObject); //This to update
the NSMutableArray and so the list displayed in your component
editingContext.deleteObject(aSpecificTargetObject); //To update the
editing context so everything will be saved correctly when you'll
saveChanges()
Hope this help (and works;))
Xavier
I'm stumped. I guess I'm just overlooking something very obvious.
I'm hoping that some wiser head hereabouts can help me. Thanks in
advance.
My problem is not the usual one implied by the subject line. I am
_not_ trying to refresh data in a to-many relationship that may
have been changed in another object store. For purposes of my
problem you can assume there is only one object store, one editing
context (the session's default) and one user involved.
I have a source object, sourceObj, with a to-many relationship. Say
the relationship key is "targets" . I obtain the related objects by
invoking sourceObj.targets() where the method targets() returns an
NSArray as a cover for a call to storedValueForKey( "targets" ).
I now invoke:
/* Assume editingContext exists and all EOs are in it */
editingContext.deleteObject( aSpecificTargetObject )
Upon subsequent invocations of targets() (and prior to saveChanges
()) the returned array contains the target object I just deleted.
This is my problem: I think that object should no longer be in the
array.
It seems the only way I can see the effects of the deletion is by
executing this sequence:
editingContext.deleteObject( aSpecificTargetObject );
editingContext.saveChanges();
editingContext.refreshObject( sourceObject ); /* If I don't do this
I still see the deleted object */
However, I don't want immediately to save the changes, so this
approach is unsatisfactory to me. (And I prefer not to use display
groups.)
Any ideas?
Thanks
Tom
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40anazys.com
This email sent to email@hidden
_______________________________________________
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