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

can I use fetch spec to filter an array?


  • Subject: can I use fetch spec to filter an array?
  • From: Denis Stanton <email@hidden>
  • Date: Wed, 31 Dec 2003 09:34:23 +1300

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.

  • Follow-Ups:
    • Re: can I use fetch spec to filter an array?
      • From: Chuck Hill <email@hidden>
    • Re: can I use fetch spec to filter an array?
      • From: Jonathan Rochkind <email@hidden>
References: 
 >Re: JPDA on Mac OSX? (From: arturo <email@hidden>)

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