Predicates: Trying to filter against max()
Predicates: Trying to filter against max()
- Subject: Predicates: Trying to filter against max()
- From: Fritz Anderson <email@hidden>
- Date: Wed, 5 Apr 2006 16:54:26 -0500
I have an entity, Bank, which contains Entrys in its relationship
"table". Entry has an int attribute, "ordinal".
I want to find the Entry with the highest ordinal. I can do this by
sorting an array derived from the set returned for the "table"
relationship, and taking the last one; but it seems to me I should be
able to filter the array with an NSPredicate like "ordinal == max
(ordinal)".
biggestEntry = [allEntries filteredArrayUsingPredicate: [NSPredicate
predicateWithFormat:
@"ordinal == max(ordinal)"]];
The predicate parser chokes on this, saying that I'm asking for an
NSEnumerator over an NSNumber. Okay, maybe it wants a source to
iterate over; try "ordinal == max(SELF.ordinal)". This doesn't work;
again the parser complains that there is no such method as -
[NSCFNumber objectEnumerator].
I'm dense, I guess, but how do I do this? "By iterating over the
array, or sorting it" would miss my point. The max() function exists
in the predicate language for _some_ reason. What is that reason, if
not for this case?
-- F
--
Fritz Anderson -- http://www.manoverboard.org/
Consulting Programmer -- http://resume.manoverboard.org/
Step into Xcode, Now Available -- http://six.manoverboard.org/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden