title: Adding extra sections to a NSFetchedResultsController
body: <p>I'm writing a small iPhone app for my company that shows bookings for each employee one week at a time. I'm using core data to get a list of 'Bookings' for a given week and want to display them in a UITableView broken down in to one section per day of the week.</p>
  
  <p>The problem comes in that I need to show 7 sections for each day of the week (showing a 'No Bookings' cell where a section/date has no bookings).</p>
  
  <p>I've got a screenshot of the app as it stands <a href="http://gallery.80nd.co.uk/main.php?g2_itemId=3036">here</a> (sorry can't post images yet as I'm new to StackOverlow) </p>
  
  <p>At the moment I'm achieving this by using a 'fetchResults' method which gets the bookings and organises them in to an array of possible dates:</p>
  
  <pre><code>- (void)refetchResults {    
  
  // Drop bookings Array, replacing with new empty one
  // 7 slots for 7 days each holding mutable array to recieve bookings where appropraite
  self.bookings = [NSArray arrayWithObjects:[NSMutableArray array],
                    [NSMutableArray array], [NSMutableArray array],
                    [NSMutableArray array], [NSMutableArray array],
                    [NSMutableArray array], [NSMutableArray array], nil];
  
  // Create the fetch request for the entity.
  NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
  NSEntityDescription *entity = [NSEntityDescription entityForName:@"Booking" inManagedObjectContext:self.managedObjectContext];
  [fetchRequest setEntity:entity];
  
  // Limit to this weeks data
  [fetchRequest setPredicate:
   [NSPredicate predicateWithFormat:@"(date &gt;= %@) &amp;&amp; (date &lt;= %@) &amp;&amp; (resource == %@)",
    firstDate,lastDate,resourceId]];
  
  // Edit the sort key as appropriate.
  NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:YES];
  NSSortDescriptor *sortDescriptor2 = [[NSSortDescriptor alloc] initWithKey:@"recId" ascending:YES];
  NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, sortDescriptor2, nil];
  [fetchRequest setSortDescriptors:sortDescriptors];
  
  // Fetch records in to array
  NSError *error;
  NSArray *results = [self.managedObjectContext executeFetchRequest:fetchRequest error:&amp;error];
  if (results == nil) {
      NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
      abort();
  }
  
  [fetchRequest release];
  [sortDescriptor release];
  [sortDescriptor2 release];
  [sortDescriptors release];
  
  // Walk through records and place in bookings Array as required
  for (Booking *item in results) {
      // Decide on array index by difference in firstDate and booking date
      int idx = (int)[[item date] timeIntervalSinceDate:firstDate]/86400;
      // Add the item to the approp MutArray
      [(NSMutableArray *)[bookings objectAtIndex:idx] addObject:item];
  }
  
  // Reload table
  [tableView reloadData];
  </code></pre>
  
  <p>}</p>
  
  <p>My question is: is there any way to achieve the same result using NSFetchedResultsController? Somehow I'd need to get the NSFetchedResultsController to have 7 sections, one for each day of the week, some of them possibly having no bookings.</p>
  
  <p>Any help much appreciated :)</p>