Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to limit the result count of NSFetchRequest?

I want to have a feature of "Recent 20 Items" in my iOS app. I use Core Data and NSFetchRequest. How can I limit the result number to 20 to achieve this? Thank you in advance!

Kai.

like image 701
nonamelive Avatar asked Feb 15 '11 07:02

nonamelive


2 Answers

set the fetchLimit of the NSFetchRequest

[request setFetchLimit:20];
like image 67
Matthias Bauch Avatar answered Oct 26 '22 01:10

Matthias Bauch


Swift 3.0 uses:

request.fetchLimit = 20
like image 34
CodeBender Avatar answered Oct 26 '22 03:10

CodeBender