Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fetch section name when using NSFetchedResultsController and sectionNameKeyPath is a relationship?

In the following code:

NSFetchedResultsController *frc =
[[NSFetchedResultsController alloc]
 initWithFetchRequest:fetchRequest
 managedObjectContext:myManagedObjectContext
 sectionNameKeyPath:@"store"
 cacheName:@"SomeCache"
 ];

The @"store" value for sectionNameKeyPath actually points to a relationship to a Store entity which has a name attribute that I really need as my section header title.

But the way my code is setup it cannot be accomplished as I instead get section titles like: 0x5b504f0 0x5b51190 Which are code data addresses for the Store object being fetched as far as I can tell.

How can I use NSFetchedResultsController so that I may tell it that I want it to fetch the name attribute of whatever it fetches from sectionNameKeyPath:@"store" ? Or is there some other workaround?

like image 733
pulkitsinghal Avatar asked Aug 31 '11 00:08

pulkitsinghal


1 Answers

Try sectionNameKeyPath:@"store.name"

like image 102
amattn Avatar answered Oct 16 '22 23:10

amattn