How to limit the result count of NSFetchRequest?

nonamelive picture nonamelive · Feb 15, 2011 · Viewed 10.7k times · Source

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.

Answer

Matthias Bauch picture Matthias Bauch · Feb 15, 2011

set the fetchLimit of the NSFetchRequest

[request setFetchLimit:20];