Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing a NSFetchedResultsController with an NSManagedObject and fetched properties
    primarykey
    data
    text
    <p>I have a database of <code>Card</code>s and <code>Printing</code>s that I have in one store (reference data) and my user's data of <code>Container</code>s and <code>CardInstance</code>s in another store (as Apple suggests). Each user's card is a table <code>CardInstance</code> that contains a specific <code>printingID</code> that corresponds with a specific printing of a card. I'm trying to use a <code>NSFetchedResultsController</code> to filter the values of the cards so that it can manage the groupings and stuff using reusable code.</p> <p>Again, here's the basic overview of the tables: <code>Card</code> (which has <code>nameNormalized</code> and <code>alphaNormalized</code> and <code>typeNormalized</code> properties that I want to filter and group on in the Fetched Results Controller). <code>Printing</code> (which has a <code>card</code> relationship and a specific <code>printingID</code>) <code>CardInstance</code> (which has a <code>container</code> relationship, a <code>printingID</code> property, and a <code>printingFetch</code> fetched property on <code>Printing</code> with predicate: <code>printingID = $FETCH_SOURCE.printingID</code>). <code>Container</code> (which has a to-many relationship of <code>CardInstance</code>s).</p> <p>Given a <code>Container</code>, 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 <code>CardInstance</code> and one predicate to <code>container = %@</code>, the given container. </p> <p>1) How do I set the sort descriptors so that I can sort on <code>printingFetch.card.nameNormalized</code> or on <code>printingFetch.card.typeNormalized</code>?</p> <p>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 <code>printingFetch.card.nameNormalized contains %@</code>, @"the", but that just results in a crash.</p> <p>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 <code>NSFetchedResultsController</code> should automatically do for me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload