要获取一定数量的记录,[fetchRequest setFetchLimit:30]
请结合您想要的 NSPredicate 实例使用限定条件。
要检索某个时间范围内的元素,您需要首先计算所需时间段的开始和结束 NSDate 实例,然后编写谓词实例,如下所示:
NSPredicate *predicate = [NSPredicate predicateWithFormat:
@"(date >= %@) AND (date <= %@)", startDate, endDate];
看到这个和这个。