• 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
Re: can I use fetch spec to filter an array?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: can I use fetch spec to filter an array?


  • Subject: Re: can I use fetch spec to filter an array?
  • From: Jonathan Rochkind <email@hidden>
  • Date: Tue, 30 Dec 2003 14:49:07 -0600

Not an EOFetchSpecification, but an EOQualifier. See EOQualifier.filteredArrayWithQualifier.

I don't understand exactly what you want to do, so I'm not sure exactly how to do it, but if you want to filter an array in memory, EOQualifier.filteredArrayWithQualifier is what you are looking for.

At 9:34 AM +1300 12/31/03, Denis Stanton wrote:
I thought I knew this, but now I can't find any mention in the API

Can I use a fetch specification to filter an array in memory, as opposed to an entity in a database?

I have written an application for a travel company. They need a report showing the total value of bookings received from each agent over a data range. Actually there are about 11 totals per agent and say 300 agents.

For my first attempt I used a fetch spec inside a loop. For each agent I defined a fetch spec with agent name, start date and end date and then fetched all the matching records from the bookings file into an array named bookings. Then I used bookings.valueForKey("@sum.nettprice") to accumulate the total of booking.netprice(), and so on through all 11 sub totals.

Too slow.

I wondered if there was any need to re-read the database. Since there is a one-to-many relationship between agent and booking, the bookings for an agent are already in agent.bookings(), except that they have not been selected by date range. So can I apply a filter to the agent.bookings() array in memory instead of reading the Booking entity from the database using:

fetchspec = new EOFetchSpecification("Booking", qualifier, null);
MSMutableArray bookings = new NSMutableArray(editingContext.objectsWithFetchSpecification(fetchspec)


I have also tried filtering the agent.bookings() array by means of a for loop to select and copy each of the the bookings within range to a new array, but that is also slow and seems crude.

Is there a proper way to do this?

Denis
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: can I use fetch spec to filter an array?
      • From: Denis Stanton <email@hidden>
References: 
 >can I use fetch spec to filter an array? (From: Denis Stanton <email@hidden>)

  • Prev by Date: can I use fetch spec to filter an array?
  • Next by Date: Continuing saga of JPDA on Mac OSX (10.2.8, G5)
  • Previous by thread: can I use fetch spec to filter an array?
  • Next by thread: Re: can I use fetch spec to filter an array?
  • Index(es):
    • Date
    • Thread