• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problem adding an entity to a to-many relationship
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem adding an entity to a to-many relationship


  • Subject: Problem adding an entity to a to-many relationship
  • From: Keith Lander <email@hidden>
  • Date: Tue, 30 Dec 2008 15:00:30 +0000

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


  • Prev by Date: Enable repeated Keyboard Event when key stays down
  • Next by Date: Basic: How to go about implementing such a view?
  • Previous by thread: Enable repeated Keyboard Event when key stays down
  • Next by thread: Basic: How to go about implementing such a view?
  • Index(es):
    • Date
    • Thread