Objective-C を使用して、1901 年 1 月 1 日から 2000 年 12 月 31 日までの毎月 1 日を決定するための一連のコードを作成しています。この出力を取得したい:
1/1/1901
1/2/1901
1/3/1901
.
.
.
1/11/2000
1/12/2000
しかし、私は毎月の最後の日を取得しています:
31/1/1901
28/2/1901
.
.
.
30/11/2000
31/12/2000
これが私のコードです:
int main(int argc, const char * argv[])
{
@autoreleasepool {
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"dd/MM/yyyy"];
    NSDate *date = [[NSDate alloc] init];
    date = [formatter dateFromString:@"01/01/1901"];
    NSDate *stopDate = [[NSDate alloc] init];
    stopDate = [formatter dateFromString:@"31/12/2000"];
    NSCalendar *cal = [NSCalendar currentCalendar];
    while ([[date earlierDate:stopDate] isEqualToDate:date]){
        NSDateComponents *comps = [cal components:NSWeekdayCalendarUnit|NSMonthCalendarUnit|NSYearCalendarUnit fromDate:date];
        if ([comps month] == 12){
            [comps setMonth:1];
            [comps setYear:[comps year]+1];
        }else{
            [comps setMonth:[comps month]+1];
        }
        date = [cal dateFromComponents:comps];
        NSLog(@"%@",date);
    }
}
return 0;
}   
どこが間違っていますか?