Paparazzi 2 Problem when using NSFetchedResultsController in 2 UITableViewControllers ...

1 view
Skip to first unread message

wgp...@gmail.com

unread,
Mar 7, 2010, 3:39:08 AM3/7/10
to iPhone Application Development Auditors
Using NSFetchedResultsController in "PersonListViewController" with no
problems whereas using it in the "PhotoListViewController" class
results in this exception:

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

I can't figure out if this has something to do with how I defined my
data model or what. I have a "to-many" (named photos) relationship
defined from Person to Photo entity and I have an inverse, "to-one"
relationship defined from Photo to Person (named person).

The code in both controllers is almost identical.

Any ideas?

Thanks -wg

wgp...@gmail.com

unread,
Mar 8, 2010, 1:46:06 PM3/8/10
to iPhone Application Development Auditors
ANSWER: You have to modify the FlickrFetcher.h/m files and remove the
hard-coded SortDescriptor which is set to use a "name" attribute (and
thus won't work if you have an entity without a "name" property)

My solution was simply to modify modify the method that returns a
FetchedResultsController as such. This generalizes the utility method
so it can be used for all your entities in this project.

- (NSFetchedResultsController *)fetchedResultsControllerForEntity:
(NSString*)entityName withPredicate:(NSPredicate*)predicate sortedBy:
(NSString *)sortProperty;

Bill

unread,
Mar 8, 2010, 2:09:49 PM3/8/10
to iPhone Application Development Auditors
Ah yes. I ran into that long enough ago that I forgot what the problem
had been. In my case, I had the entity "user" in both Person and
Photo, so changing the key from "name" to "user" worked for me. Your
solution has a bit more grace to it, though. :-)

Bill

Reply all
Reply to author
Forward
0 new messages