0

I have an entity in my CoreData model that contains these 2 attributes:

startDate (NSDate)
terms (int)

I need to grab all the objects where the start plus the terms (which is months) is within the next 30 days.

Here is what I need to do in some pseudo code:

[NSPredicate predicateWithFormat:@"(startDate.months + terms) <= %@", date30DaysFromNow];

This may not be possible (or I am just being dumb).

I know the alternate solution would be to create a new attribute that creates this date when I import the objects.. but if I can I would rather not have to add another attribute if I don't have to.

Thanks!

4

1 回答 1

0

向模型对象添加一个属性,即 NSDate。每当更新日期或术语属性时(或根据您将其用于广告的频率按需)更新此新日期startDate.months + terms(最有可能使用NSDateComponentsor - (id)dateByAddingTimeInterval:(NSTimeInterval)seconds。然后在谓词中使用此属性。

于 2013-04-22T16:31:59.723 回答