28

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.

nonamelive
  • 6,510
  • 8
  • 40
  • 47

2 Answers2

51

set the fetchLimit of the NSFetchRequest

[request setFetchLimit:20];
Matthias Bauch
  • 89,811
  • 20
  • 225
  • 247
6

Swift 3.0 uses:

request.fetchLimit = 20
CodeBender
  • 35,668
  • 12
  • 125
  • 132