I'm working on an iPhone and I'm using Core Data as my store.
我正在使用iPhone,而我正在使用Core Data作为我的商店。
What I'd like to do is list the top 50 entities in descending order by their height.
我想做的是按高度按降序排列前50个实体。
I'm struggling to find out the syntax for the predicate.
我正在努力找出谓词的语法。
1 个解决方案
#1
68
First, go to the NSFetchRequest class reference.
首先,转到NSFetchRequest类引用。
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
并使用fetchLimit属性
[request setFetchLimit:50];
#1
68
First, go to the NSFetchRequest class reference.
首先,转到NSFetchRequest类引用。
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
并使用fetchLimit属性
[request setFetchLimit:50];