ioscore-datansfetchedresultscontrollerfetched-property

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


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.


Solution

  • 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