views:

192

answers:

2

In my core data model I have a Person entity that has a "to many" relationship a Course entity (I also have an inverse "to one" relationship from Course to Person).

Now I have a subclassed UITableViewController that uses a NSFetchedResultsController to display Person objects which works fine. I have this set up so that when you click on a Person it publishes another subclassed UITableViewController that uses a NSFetchedController as well to display the Courses associated to the person.

PROBLEM: I get this exception whenever I click on the Person and attempt to display the Course UITableViewController ...

"Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath name not found in entity <NSSQLEntity Course id=2>'"

Any ideas on how to resolve or troubleshoot?

The code between the two ViewControllers is almost identical except for the NSFetchedResultsController being configured for "Person" entities in one and "Course" entities in another

+1  A: 

The error means that a keypath, probably a relationship, that you use to define the NSFetchedResultsController does not exist in the data model. These errors often crop up in predicates and sort definitions.

Somewhere you've got a path something like" person.course.someattribute.somerelationship whereas in your model you got person.course.somerelationship. Or you might have simply misspelled something such as a key name.

TechZen
A: 

Do you access the Person object retrieved in the first view controller in the second view controller? If you do, then put a explicit retain in the first executeFetchRequest, like this:

[[[managedObjectContext executeFetchRequest:request error:&error] objectAtIndex:0] retain];

Thats because executeFetchRequest returns autorelease objects. So, you have to retain then. Hope that helps you.

R31n4ld0_