How to limit the result count of NSFetchRequest?

帅比萌擦擦* 提交于 2019-12-06 16:41:57

问题


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.


回答1:


set the fetchLimit of the NSFetchRequest

[request setFetchLimit:20];



回答2:


Swift 3.0 uses:

request.fetchLimit = 20


来源:https://stackoverflow.com/questions/5000927/how-to-limit-the-result-count-of-nsfetchrequest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!