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: Ben Trumbull <email@hidden>
- Date: Sun, 17 May 2009 14:25:01 -0700
Using the example from the guides, when I create a new employee with
Employee *newEmployee = [NSEntityDescription
insertNewObjectForEntityForName:*@"employee"* inManagedObjectContext:*
context];*
I not only get a new employee, but also a new unnamed department.
When I add
the employee to the correct department, the new unnamed department
remains
as a bonus. I've done this in steps (not using the convenience class
method), and see that the unwanted department is created in the
-initWithENtity:insertIntoManagedObjectContext method.
Core Data doesn't insert new objects by itself. You've probably added
custom code in -awakeFrom* or overridden -initWithEntity:.. to create
the department.
Alternatively, Cocoa Bindings will insert new objects if you go
through the Add action to a controller bound to the Department entity.
- Ben
_______________________________________________
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