nonamelive
nonamelive

Reputation: 6510

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.

Upvotes: 28

Views: 11541

Answers (2)

CodeBender
CodeBender

Reputation: 36610

Swift 3.0 uses:

request.fetchLimit = 20

Upvotes: 6

Matthias Bauch
Matthias Bauch

Reputation: 90117

set the fetchLimit of the NSFetchRequest

[request setFetchLimit:20];

Upvotes: 51

Related Questions