Your logic is wrong: instead of setting the day of the day to 1, you add the day to the current date.
Try something like this:
NSDate *today = [NSDate date]; NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDateComponents *components = [gregorian components:(NSEraCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit) fromDate:today]; components.day = 1; NSDate *dayOneInCurrentMonth = [gregorian dateFromComponents:components];
Fabian kreiser
source share