I have several objects set up in Core Data, one of which is "Deck" and one of which is "Card". "Cards" have several numbered relationships, including "id". "Deck" has a one-to-many relationship with cards.
What's the best way to find the Card in a Deck that has the minimum value to some numbered attribute, such as id?
Clearly I can get the list of cards like this:
NSSet *cardList = self.cards;
I think I can build an expression to get a minimum like this:
NSExpression *keyPathExpression = [NSExpression expressionForKeyPath:@"id"];
NSExpression *minExpression = [NSExpression expressionForFunction:@"min:"
arguments:[NSArray arrayWithObject:keyPathExpression]];
But I can't quite suss out how to use that expression to extract the card with the minimum value of id (or just the minimum value of id).