Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The following should work (did not actually compile and test the code)</p> <pre><code> NSEnumerator* enumerator; DiaryEntrys* currEntry; NSMutableDictionary* result; /* use sorting code from other answer, if you don't sort, the result will still contain arrays for each day of the week but arrays will not be sorted */ [myArray sortUsingDescriptors:....]; /* result holds the desired dictionary of arrays */ result=[[NSMutableDictionary alloc] init]; /* iterate throught all entries */ enumerator=[myArray objectEnumerator]; while (currEntry=[enumerator nextObject]) { NSNumber* currDayOfTheWeekKey; NSMutableArray* dayOfTheWeekArray; /* convert current entry's day of the week into something that can be used as a key in an dictionary I'm converting into an NSNumber, you can choose to convert to a maningfull string (sunday, monday etc.) if you like I'm assuming date_ is an NSCalendarDate, if not, then you need a method to figure out the day of the week for the partictular date class you're using Note that you should not use NSDate as a key because NSDate indicates a particular date (1/26/2010) and not an abstract "monday" */ currDayOfTheWeekKey=[NSNumber numberWithInt:[[currEntry valueForKey:@"date_"] dayOfWeek]]; /* grab the array for day of the week using the key, if exists */ dayOfTheWeekArray=[result objectForKey:currDayOfTheWeekKey]; /* if we got nil then this is the first time we encounter a date of this day of the week so we create the array now */ if (dayOfTheWeekArray==nil) { dayOfTheWeekArray=[[NSMutableArray alloc] init]; [result setObject:dayOfTheWeekArray forKey:currDayOfTheWeekKey]; [dayOfTheWeekArray release]; // retained by the dictionary } /* once we figured out which day the week array to use, add our entry to it. */ [dayOfTheWeekArray addObject:currEntry]; } </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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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