Number of days in the current month using iOS?
问题 How can I get the current number of days in the current month using NSDate or something similar in Cocoa touch? 回答1: You can use the NSDate and NSCalendar classes: NSDate *today = [NSDate date]; //Get a date object for today's date NSCalendar *c = [NSCalendar currentCalendar]; NSRange days = [c rangeOfUnit:NSDayCalendarUnit inUnit:NSMonthCalendarUnit forDate:today]; today is an NSDate object representing the current date; this can be used to work out the number of days in the current month.