一行代码搞定,示例代码如下:
NSDate *date = [NSDate date];
NSRange daysInLastMonth = [[NSCalendar currentCalendar] rangeOfUnit:NSCalendarUnitDay inUnit:NSCalendarUnitMonth forDate:date];
// dayCountOfThisMonth就是date月份的天数
NSInteger dayCountOfThisMonth = daysInLastMonth.length;
网友评论