I have a database of Card
s and Printing
s that I have in one store (reference data) and my user's data of Container
s and CardInstance
s in another store (as Apple suggests). Each user's card is a table CardInstance
that contains a specific printingID
that corresponds with a specific printing of a card. I'm trying to use a NSFetchedResultsController
to filter the values of the cards so that it can manage the groupings and stuff using reusable code.
Again, here's the basic overview of the tables:
Card
(which has nameNormalized
and alphaNormalized
and typeNormalized
properties that I want to filter and group on in the Fetched Results Controller).
Printing
(which has a card
relationship and a specific printingID
)
CardInstance
(which has a container
relationship, a printingID
property, and a printingFetch
fetched property on Printing
with predicate: printingID = $FETCH_SOURCE.printingID
).
Container
(which has a to-many relationship of CardInstance
s).
Given a Container
, I'm wanting to use a NSFetchedResultsController so that I can change the sort and groupings between name and type sections. So I have a fetchRequest where I've set the entity type to CardInstance
and one predicate to container = %@
, the given container.
1) How do I set the sort descriptors so that I can sort on printingFetch.card.nameNormalized
or on printingFetch.card.typeNormalized
?
2) How do I filter the results if I want to find all cards containing the word @"the"? I was thinking something along the lines of printingFetch.card.nameNormalized contains %@
, @"the", but that just results in a crash.
I realize I could do this all manually, but if the container ends up containing a lot of cards, that may be way too slow and I'd like to not have to re-write the sectioning and grouping code that NSFetchedResultsController
should automatically do for me.