Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

desc limit 50 equivalent in Core Data / NSPredicate

I'm working on an iPhone and I'm using Core Data as my store.

What I'd like to do is list the top 50 entities in descending order by their height.

I'm struggling to find out the syntax for the predicate.

like image 239
iOSDevil Avatar asked Dec 10 '09 14:12

iOSDevil


1 Answers

First, go to the NSFetchRequest class reference.

Use the sort descriptor to your fetch request :

NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES selector:@selector(caseInsensitiveCompare:)];
[request setSortDescriptors:[NSArray arrayWithObject:sort]];

And use the fetchLimit property

[request setFetchLimit:50];
like image 121
Francescu Avatar answered Oct 19 '22 15:10

Francescu