コンパイルされていません -- おそらくいくつかのトゥポがあります。
NSDateFormatter* dayFmt = [[NSDateFormatter alloc] init];
[dayFmt setTimeZone:<whatever time zone you want>];
[dayFmt setDateFormat:@"g"];
NSInteger lastDay = [[dayFmt stringFromDate:startDate] integerValue];
// Note: We assume that myDates is sorted, as stated.
for (NSDate* myDate in myDates) {
NSInteger myDay = [[dayFmt stringFromDate:myDate] integerValue];
while (myDay > lastDay+1) {
lastDay++;
NSDate* newDate = [dayFmt dateFromString:[NSString stringWithFormat:@"%d", lastDay]];
[missingDates addObject:newDate];
}
}
(最後の配列エントリと任意の終了日の間に欠落している日付を埋める方法をユーザーが理解するための演習として残します。)
(コードは、配列に重複する日付がないことを前提としていることにも注意してください。簡単に処理できますが、ユーザーにとっては別の課題です。)