我想在循环中增加天数,以便计数2012-11-10
, 2012-11-11
, 2012-11-12
, ...</p>
实现这一目标的最有效方法是什么?
NSDate *iterationDate = [NSDate date];
for (int i = 0; i < 100; i++) {
NSDateComponents *comps = [[NSDateComponents alloc] init];
[comps setYear:0];
[comps setMonth:0];
[comps setWeek:0];
[comps setDay:1];
[comps setHour:0];
[comps setMinute:0];
[comps setSecond:0];
iterationDate = [currentCalendar dateByAddingComponents:comps toDate:iterationDate options:0];
}