如何从核心数据中检索上个月的条目
我如何要求核心数据获取最近输入的 30 个元素,或者今天一个月内输入的元素?
how do I ask core data to fetch me the last 30 elements entered or alternatively the elements entered within a month of today?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要获取一定数量的记录,请结合使用
[fetchRequest setFetchLimit:30]
等限定条件以及所需的 NSPredicate 实例。要检索某个时间范围内的元素,您需要首先计算所需时间段的开始和结束 NSDate 实例,然后对谓词实例进行编码,如下所示:
请参阅 这个 和 这个。
To fetch a certain number of records, use qualification like
[fetchRequest setFetchLimit:30]
in combination with NSPredicate instance you desired.To retrieve elements within a range of time, you need first calculate the beginning and the end NSDate instances of the period you want, then code your predicate instance like:
See this and this.