How can I created a fetched property to get the entity with a minimum field?

Go To StackoverFlow.com

0

I can't solve this problem... I'm having some problems with fetched properties (not with fetched requests).

How can I created a fetched property to get the entity with a minimum field? If you see these captures, you will see it: enter image description here enter image description here

What I have to write in fetched property called minItemTimestamp? I tried several options but don't work. "@min.items.timestamp" "items.@min.timestamp" @min seems it is an aggregate and not sure that is what I'm looking for.

I tried this reply, but no luck: Fetched Property in XCode Data Model Editor for minimum value

So, can I create a fetched property to get from all items that belong to current category, the one with minimum timestamp?

Thanks a lot, I appreciate your help a lot.

2012-04-05 00:21
by Ricardo


1

You do not need a fetched property.

use the following lines of code:

id minTimestamp=[myCategory.items valueForKeyPath:@"@min.timestamp"];
id maxTimestamp=[myCategory.items valueForKeyPath:@"@max.timestamp"];

see using a @min in predicate

2012-04-05 17:08
by javieralog
I got it! Thanks a lot - Ricardo 2012-04-09 15:07


0

The NSFetchedResultsController will accept an array of NSSortDescriptors via a property and will sort the data for you accordingly.

2012-04-05 00:34
by borrrden
I don't understand it. Can you explain it in a different way, please - Ricardo 2012-04-05 16:40
Nevermind, you removed the part of the question I was answering.. - borrrden 2012-04-05 23:34
Sorry. I fixed that part accessing the relationship. Something like items.count - Ricardo 2012-04-06 13:05
Ads