Re: Core Data Implementation question
Re: Core Data Implementation question
- Subject: Re: Core Data Implementation question
- From: Charilaos Skiadas <email@hidden>
- Date: Wed, 20 Jul 2005 12:25:09 -0500
On Jul 20, 2005, at 12:03 PM, Marcus S. Zarra wrote:
I am trying to figure out the best way to approach this issue with
Core
Data.
I have a parent object that has a to-many relationship with a child
object.
The child has a to-one relationship with the parent.
Parent <-->> Child
Adding new children works correctly and the GUI (which displays the
children
in a table) works perfectly.
The problem comes in with a couple of attributes in the parent. The
parent
has a couple of values that are changed based on the children. The
children
are added progammatically and I need a way to notify any observers
that the
parent attributes have changed when I add the child. I have tried
doing the
following:
Are the values only changing when a child is added? In that case, you
should I think be able to just use the "derived value" approach
described in
http://developer.apple.com/documentation/Cocoa/Conceptual/
NSPersistentDocumentTutorial/03_CustomClass/
chapter_4_section_3.html#//apple_ref/doc/uid/TP40001799-CH219-
DontLinkElementID_14
and the the "children" key as the key in the "initialize" method that
triggers the notification.
If on the other hand the attributes depend on attributes in the
children themselves, then I am not too sure what the best way to
accomplish that is, but I sure would like to know.
[parent willChangeValueForKey:@"xxx"];
//add child
[parent didChangeValueForKey:@"xxx"];
but this seems to mess up the actual update of the child.
Does anyone know of a cleaner way to get this to work? Note that
the parent
attribute "xxx" is a calculated value in the parent object and not
a value
stored in the core data repository.
Thanks for any insight.
Marcus S. Zarra
Haris
_______________________________________________
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