Re: Core Data Problem: Creating a child object creates unwanted parent
Re: Core Data Problem: Creating a child object creates unwanted parent
- Subject: Re: Core Data Problem: Creating a child object creates unwanted parent
- From: Kent Hauser <email@hidden>
- Date: Wed, 13 May 2009 12:26:25 -1000
Jerry,
Sorry I wasn't clearer. My example of employee & department was in reference
to the inverse-relationship example in the Core Data Programming guide. My
actual application involves adding taskRecords to a student object, and I
was just using the department-employee as an example of a to-many with
inverse relationship.
My actual problem is that when I create a new taskRecord (in a tableView
delegate helper method I call 'getMutableTaskRecord'), the new taskRecord
entity is created and added to the student's to-many taskRecords. The
inverse in the new taskRecord is set to the student automagically when I
invoke [student addTaskRecordsObject:newTask]. Everything is perfect --
except that every time I create a taskRecord, I create a new Student! I can
go into my student editor & delete them, but needless to say, something's
not right.
Hope that clarifies my issue.
Thanks for the input.
Kent
On Wed, May 13, 2009 at 11:43 AM, Jerry Krinock <email@hidden> wrote:
>
> Well, I don't know what you're doing wrong. Actually I'm not sure what is
> the undesired behavior your are seeing. But let me explain something...
>
> That department creation you are referring to in the DepartmentAndEmployees
> sample occurs within the document's -initWithType:error: implementation.
> This is a slightly odd implementation, but it is to satisfy the slightly
> odd design requirement that each document have one and only one '
> department' object, and that this object be inserted immediately when a
> new document is created.
>
> The 'department' is thus created when the document is created, not when a
> child is created.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden