#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

	int year = 2000;
	int month = 2;
	
	NSCalendar *cal = [[NSCalendar alloc]
					   initWithCalendarIdentifier:NSGregorianCalendar];
	NSDateComponents *theDay = [[NSDateComponents alloc] init];
	
	//次の月の0日に
	[theDay setYear:year];
	[theDay setMonth:month + 1];
	[theDay setDay:0];
	
	NSDate *date = [cal dateFromComponents:theDay];
	NSDateComponents *newComp = [cal components:NSDayCalendarUnit fromDate:date];
	
    NSLog(@"year:%d month:%d -> %ddays", year, month, [newComp day]);
    [pool drain];
    return 0;
}
