Hi Gustavo,

How about setting the sort descriptor’s ascending to NO, and limit the number 
of fetched objects to one?  Something like this…?

        [request setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor 
sortDescriptorWithKey:@"date" ascending:NO]]]; // descending = arranged from 
largest (latest)
        [request setFetchLimit:1];

-ev

On May 15, 2011, at 18:02, Gustavo Pizano wrote:

> Hello all.
> 
> I have a Entity A      that has a to-many relationship. to B
> 
> Now I need to get the latest B of A.
> 
> I was reading NSFetchRequest, and NSPredicate, for NSPredictate I could use 
> something like
> 
> predicate = [NSPredicate predicateWithFormat:@"birthday > %@", referenceDate];
> filteredArray = [array filteredArrayUsingPredicate:predicate];
> 
> but the operator is a comparison,  I wish to know if its possible to fetch 
> the object with he latest date without having to looping through the objects 
> manually and comparing the dates.
> 
> And NSFetchRequest will fetch me on the whole table of B.
> 
> 
> I know its silly question but I hadn't found the way..
> 
> thanks
> 
> 
> Gustavo
> 
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/ev%40monoceroi.com
> 
> This email sent to e...@monoceroi.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to