Re: Problem adding an entity to a to-many relationship
Re: Problem adding an entity to a to-many relationship
- Subject: Re: Problem adding an entity to a to-many relationship
- From: "Marcus S. Zarra" <email@hidden>
- Date: Thu, 1 Jan 2009 11:18:16 -0700
Can you share the code for this call:
[course addStudentsObject:student];
That method is not part of the API so I am guessing you wrote it. If
we can get a peak into there we can see what the issue is.
Marcus S. Zarra
Zarra Studios LLC
Simply Elegant Software for OS X
www.zarrastudios.com
On Dec 30, 2008, at 8:00 AM, Keith Lander wrote:
I am trying to get my head round Core Data and Bindings. I have
created a simple core data model consisting of two entities called
Course and Student. There is a to-many relationship from Course to
Student. I have created a view with one table for Courses and
another for students. There is a button for adding courses. That
works fine. I also have a button which when clicked gets a CSV file
containing student details. For each student in the file I want to
create a new entity and have the following code in my
NSPersistentDocument subclass:
NSManagedObjectContext *context = [self managedObjectContext];
Student *student = [NSEntityDescription
insertNewObjectForEntityForName:@"Student"
inManagedObjectContext:context];
This seems to work OK. I then update the fields with data from the
CSV file.
The problem comes when I try to add the student to its owning course.
I get the course from the array controller using:
Course *course = [[coursesController selectedObjects] objectAtIndex:
0];
This seems to return the correct entity.
Then I then add the student using the predefined accessor:
[course addStudentsObject:student];
This fails in the call [NSBinder
_invokeSelector:withAguments:onKeyPath:ofObject:mode:raisesForNotApplicableKeys
:]
I'm using the latest version of XCode and have got garbage
collection switched on.
I hope someone can sort me out.
Cheers
Keith
_______________________________________________
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
_______________________________________________
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