• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Predicates: Trying to filter against max()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Predicates: Trying to filter against max()
      • From: Sean Murphy <email@hidden>
  • Prev by Date: Re: How to tell linker to bind init at runtime
  • Next by Date: Re: How to copy without losing information
  • Previous by thread: Reporting Charting generator
  • Next by thread: Re: Predicates: Trying to filter against max()
  • Index(es):
    • Date
    • Thread