AWSからの各曜日のデータをカウントしようとしています。週の最初の日は月曜日に設定されます。これにより、プログラムが無限ループ内で実行されます。なぜそれを得ることができないようです。
-(void)weekSectionSorting{
NSCalendar* calendar = [NSCalendar currentCalendar];
[calendar setTimeZone:[NSTimeZone timeZoneWithName:@"Asia/Singapore"]];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; // Initialize NSDateFormatter.
NSDate *today = [NSDate date];
NSDateComponents* comps = [calendar components:NSYearForWeekOfYearCalendarUnit |NSYearCalendarUnit|NSMonthCalendarUnit|NSWeekCalendarUnit|NSWeekdayCalendarUnit fromDate:today];
[comps setWeekday:2]; // 2: monday
NSDateComponents* todayDc = [calendar components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:today];
NSDateComponents* oneDay = [[NSDateComponents alloc] init];
[oneDay setDay:1];
[dateFormatter setDateFormat: @"dd-MM-yyyy"];
BOOL notToday = YES;
int count = 0;
NSDate *d = [calendar dateFromComponents:comps];
DLog(@"First day of week : %@", [dateFormatter stringFromDate:d]);
while (notToday) {
count += [[self.dataDict objectForKey:[dateFormatter stringFromDate:d]] count];
DLog(@"%i",count);
NSDateComponents* curDc = [calendar components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:d];
if ([curDc year] == [todayDc year] && [curDc month] == [todayDc month] && [curDc day] == [todayDc day]) {
notToday = NO;
}
d = [calendar dateByAddingComponents:oneDay toDate:d options:0];
}
}