¡@

Home 

2014/10/15 ¤U¤È 10:13:08

iphone Programming Glossary: rangeofunit

Number of days in the current month using iPhone SDK?

http://stackoverflow.com/questions/1179945/number-of-days-in-the-current-month-using-iphone-sdk

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.. used in conjunction with the NSDate for the current date to return the number of days in the current month using the rangeOfUnit inUnit forDate function. days.length will contain the number of days in the current month. Here are the links to the docs..

Get all days of any month with objective-c

http://stackoverflow.com/questions/1731322/get-all-days-of-any-month-with-objective-c

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 I basically want to use that but replace today with say the month.. NSDateComponents comps NSDateComponents alloc init autorelease Set your month here comps setMonth 1 NSRange range cal rangeOfUnit NSDayCalendarUnit inUnit NSMonthCalendarUnit forDate cal dateFromComponents comps NSLog @ d range.length share improve..

How do I calculate the number of days in this year in Objective C

http://stackoverflow.com/questions/2078372/how-do-i-calculate-the-number-of-days-in-this-year-in-objective-c

of days in a year for any calendar not just gregorian. I have tried this NSUInteger days NSCalendar currentCalendar rangeOfUnit NSDayCalendarUnit inUnit NSYearCalendarUnit forDate NSDate date but that gives me the number of days in the current month.. date NSDateComponents components calendar components NSYearCalendarUnit fromDate today NSUInteger months calendar rangeOfUnit NSMonthCalendarUnit inUnit NSYearCalendarUnit forDate today .length for int i 1 i months i components.month i NSDate.. .length for int i 1 i months i components.month i NSDate month calendar dateFromComponents components days calendar rangeOfUnit NSDayCalendarUnit inUnit NSMonthCalendarUnit forDate month .length return days It is not as neat as I would have hoped..