NSCalendar を「いじる」ことを恐れているのはなぜですか? NSDateComponents メソッドを使用するには、実際には NSCalendar を使用する必要があります。これがあなたの問題に対する私の解決策です。
// Get the current weekday
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *weekdayComponents = [calendar components:NSWeekdayCalendarUnit fromDate:[NSDate date]];
// !! Sunday = 1
NSInteger weekday = [weekdayComponents weekday];
これで、インデックス 0 で日曜日から始まる平日を含むNSDateFormatterメソッド-(NSArray *) weekdaySymbolsを使用できます。 :
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
// !! Sunday = 0
NSUInteger symbolIndex = (weekday < 7) ? weekday : 0;
NSString *weekdaySymbol = [[formatter weekdaySymbols] objectAtIndex:(NSUInteger)symbolIndex];
ある程度NSCalendarを使っていますが、参考になれば幸いです。
編集: glektrik のソリューションは非常に簡単です。ただし、NSDate クラス リファレンスの- dateByAddingTimeInterval:の次のステートメントに注意してください。
戻り値:
受信者に対して秒数秒に設定された新しい NSDate オブジェクト。返された日付は、受信者のものとは異なる表現を持つ場合があります。