0

I have a list of birthdays. From the list of b'days, I need to select all the b'days which occurs in the next 30 days.

For example : Today's date is 07/13, then I need to list all the b'days which occurs between 07/13 and 08/13.

Is there any built in method to select the dates in this manner.

Thanks in advance

4

2 に答える 2

2

これに使用できますNSPredicate

NSDate *now = [NSDate date];
NSDate *later = [now dateByAddingTimeInterval:(30*24*60*60)];
NSPredicate *pre = [NSPredicate predicateWithFormat:@"SELF >= %@ AND SELF <= %@", now, later];
NSArray *upcomingBirthdays = [birthdays filteredArrayUsingPredicate:pre];
于 2012-07-13T05:40:18.800 に答える
0

自分でロジックを作成する必要があります。ここに「日付と時刻のプログラミングガイド」へのリンクがあります。「日付」が 1 週間以内かどうかを確認するサンプル コードが含まれています。始めるには良い場所かもしれません。

アップルのガイド

于 2012-07-13T05:37:51.323 に答える