NSCalendar *gregorian = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
NSDate *date = [NSDate date];
NSDateComponents *weekdayComponents = [gregorian components:NSWeekdayCalendarUnit fromDate:date];
NSInteger todayWeekday = [weekdayComponents weekday];
enum Weeks {
SUNDAY = 1,
MONDAY,
TUESDAY,
WEDNESDAY,
THURSDAY,
FRIDAY,
SATURDAY
};
NSInteger moveDays=SATURDAY-todayWeekday;
if (moveDays<=0) {
moveDays+=7;
}
NSDateComponents *components = [NSDateComponents new];
components.day=moveDays;
NSCalendar *calendar=[[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar];
NSDate* newDate = [calendar dateByAddingComponents:components toDate:date options:0];
NSLog(@"%@",newDate);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…