我正在尝试使用NSDates创建一个for循环,以便循环在for循环的每个循环中增加1天...
NSDate *startDate = datePicker.date;
NSDate *endDate = datePicker2.date;
for (int i = startDate; i < endDate; i++)
{
}
构建失败是因为我干扰了NSDate,其中int是...... 我也试过......
NSDate *startDate = datePicker.date;
NSDate *endDate = datePicker2.date;
for (NSDate *i = startDate; i < endDate; i++)
{
}
那也没有。非常感谢任何帮助,提前谢谢。
答案 0 :(得分:3)
for (NSDate *date = [startDate copy]; [date compare: endDate] < 0; date = [date dateByAddingTimeInterval:24 * 60 * 60] )
{
NSLog( @"%@ in [%@,%@]", date, startDate, endDate );
}