So i've been trying to find the last day of the month in an int but the code I'm using always thinks the last day is 30
the code i am using looks like this
NSDate *curDate = [NSDate date];
NSCalendar* calendar = [NSCalendar currentCalendar];
NSDateComponents* compsd = [calendar components:NSYearCalendarUnit|NSMonthCalendarUnit|NSWeekCalendarUnit|NSWeekdayCalendarUnit fromDate:curDate]; // Get necessary date components
// set last of month
[compsd setMonth:[compsd month]+1];
[compsd setDay:0];
NSDate *tDateMonth = [calendar dateFromComponents:compsd];
//NSLog(@"%@", tDateMonth);
//[comps setMonth:[comps month]+1];
//[comps setDay:0];
// NSDate *tDateMonth = [cal dateFromComponents:comps];
//NSLog(@"%@", tDateMonth);
//*/
NSString *tDateString = [NSString stringWithFormat:@"%@", tDateMonth];
NSString *dateNTime = [[tDateString componentsSeparatedByString:@"-"] objectAtIndex:2];
int justDate = [[[dateNTime componentsSeparatedByString:@" "] objectAtIndex:0] intValue];
NSLog(@"Last Day of %@ is %d", monthName, justDate);
What am I missing?