Obtenga la date del próximo sábado en Objective-C?

¿Cómo obtendrías la date del primer sábado que ocurre después de hoy en Objective-C para iOS?

Esto lo guiará a través del process de manipulación de las dates del calendar:

Cálculos calendáricos

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); 

[NSDate dateWithNaturalLanguageString: @"next Saturday"]


Editar: Comenzando en OS X 10.9 y iOS 8, puede hacer esto:

 NSCalendar *calendar = [NSCalendar currentCalendar]; NSDate *now = [NSDate date]; NSDateComponents *saturday = [[NSDateComponents alloc] init]; saturday.weekday = 7 /* Saturday */; NSDate *nextSaturday = [calendar nextDateAfterDate:now matchingComponents:saturday options:0];