本文介绍了日期的核心数据 NSPredicate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的模型中,我有日期属性并且我设置了它[NSDate date],但是得到像

In my model I have date attribute and I set it [NSDate date], but getting with predicate like

 NSPredicate *predicate = [NSPredicate predicateWithFormat:
                              @"date==%@ ,date];

返回notting.我知道问题是当我设置 [NSDate date] 它也存储时间并且 NSPredicate 总是返回空数据.有没有办法将 "date==%@" 部分转换为只查找日期?

returns notting. I know the problem is when I set [NSDate date] it stores also time and NSPredicate always return empty data. Is there any way to convert "date==%@" part to only look for date?

推荐答案

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(date >= %@) AND (date <= %@)", startDate, endDate];

这篇关于日期的核心数据 NSPredicate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 17:28