[iOS]取得當月有多少天
- ( NSInteger )getNumberOfDaysInMonth { NSCalendar * calendar = [[ NSCalendar alloc ] initWithCalendarIdentifier : NSCalendarIdentifierGregorian ]; NSDate * currentDate = [ NSDate date ]; NSRange range = [calendar rangeOfUnit : NSCalendarUnitDay inUnit : NSCalendarUnitMonth forDate :currentDate]; return range. length ; }