且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

iPhone:如何在两个选定日期之间找到日期?

更新时间:2021-07-19 22:57:20

尝试 dateWithTimeInterval:SinceDate:

NSMutableArray dates = [NSMutableArray array];
NSDate *curDate = startDate;
while([curDate timeIntervalSince1970] <= [endDate timeIntervalSince1970]) //you can also use the earlier-method
{
    [dates addObject:curDate];
    curDate = [MSDate dateWithTimeInterval:86400 sinceDate:curDate]; 86400 = 60*60*24
}
//here maybe an additional check if the enddate has to be inserted or not