2

Using a NSCalendar os anything else, is it possible to get the number of days of the month of a given NSDate ?

Abramodj
  • 5,709
  • 9
  • 49
  • 75

1 Answers1

5

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
Community
  • 1
  • 1
Robert
  • 21,110
  • 9
  • 55
  • 65