• 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: Core Data Fetch Request Template
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data Fetch Request Template


  • Subject: Re: Core Data Fetch Request Template
  • From: Colin Doncaster <email@hidden>
  • Date: Mon, 21 Aug 2006 15:14:29 +1000

Hey there -

Does it really make sense to "fetch" the maximum value of a object stores in the persistent store? I'm assuming you want to retrieve the object with the maximum value? The way I'd go about doing this ( it might not be the correct way ) without knowing what the maximum value is, is to do a fetch request with a sort descriptor, then sort them based on "value" descending, then just use the first index of the array. If it's sorted correctly that should be the maximum value.

If there is a chance more than one of them matches a max value then once you've figured out the maximum value ( with the retrieved object above ) then perform another fetch request finding all objects that match that value.

Not too sure how you would avoid the two step process when doing a fetch request. The concept seems slightly different to me as rather than trying to return the exact data ( as with NSArray ) you're actually requesting the containers for the data.

I could be wrong though.

Cheers.

On 21-Aug-06, at 9:11 AM, Niels Meersschaert wrote:

I'm trying to see how this is possible to do directly in the model. I have an entity with several attributes. I'd like to create a fetch request in the model which is based on an expression like @max, @sum, etc of one of the attributes of an entity. However, whenever I try doing this in the model, it won't let me compile saying the syntax can't be parsed. I've tried using the predicate builder & selecting expression, but no joy as it says it's not the correct format. I am able to do the same functionality with bindings setting my model key path to @max.attributeName. How can I configure a fetch request in the model such that I can get all entities whose attribute is the max like I can in the binding?

Thanks,

Niels

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40colindoncaster.com


This email sent to email@hidden

_______________________________________________ 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
References: 
 >Core Data Fetch Request Template (From: Niels Meersschaert <email@hidden>)

  • Prev by Date: Bindings and NSTableColumns
  • Next by Date: Re: Sub NSToolbar???
  • Previous by thread: Core Data Fetch Request Template
  • Next by thread: Sub NSToolbar???
  • Index(es):
    • Date
    • Thread