开发者

How can i know the number of days of a month?

Using a NSCalendar os anyt开发者_JS百科hing else, is it possible to get the number of days of the month of a given NSDate ?


Get all days of any month with objective-c

Duplicate from there apparently, anyways, I'll keep this here.

NSCalendar* a = [NSCalendar currentCalendar];
NSDateComponents* b = [[[NSDateComponents alloc] init] autorelease];
[b setMonth:1]; // The Month
NSRange c = [a rangeOfUnit:NSDayCalendarUnit
                          inUnit:NSMonthCalendarUnit
                         forDate:[a dateFromComponents:b]];
// c.length will have the amount of days
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜