views:

385

answers:

1

Hi,

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.

+5  A: 

Hi

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];
F.Santoni
Spot on, thank you
Andrew
You're welcome ! Good luck
F.Santoni