Note that there are some explanatory texts on larger screens.

plurals
  1. POFirst dayof the week - iOS
    primarykey
    data
    text
    <p>I'm trying to count the data for each date of the week from a AWS. The first day of the week is set to monday. This causes my program to run inside a infinite loop. Can't seem to get it why.</p> <pre><code>-(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] &amp;&amp; [curDc month] == [todayDc month] &amp;&amp; [curDc day] == [todayDc day]) { notToday = NO; } d = [calendar dateByAddingComponents:oneDay toDate:d options:0]; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload