title: Fetching and sorting objects into sections
body: <p>In my tableView I have fixed sections and fixed section titles. This is the code for this part of my requirements:</p>
  
  <pre><code>- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  {
      return 6;
  }
  
  
  + (NSString*) titleForHeaderForSection:(int) section
  {
      switch (section)
      {
          case 0 : return @"Overdue";
          case 1 : return @"Today";
          case 2 : return @"Tomorrow";
          case 3 : return @"Upcoming";
          case 4 : return @"Someday";
          case 5 : return @"Completed";
          //default : return [NSString stringWithFormat:@"Section no. %i",section + 1];
      }
  }
  
  - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
  {
      return [CollapsableTableViewViewController titleForHeaderForSection:section];
  }
  </code></pre>
  
  <p>This part is working fine, but now I want to populate the sections with core data objects.
  For this part and prior to fetching the results, I have following code:</p>
  
  <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  {
      NSError *error = nil;
      if (![[self fetchedResultsController] performFetch:&amp;error])
      {
          NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
          abort();
      }
  
  
      switch (section)
      {
          case 2 : return 3;
          case 3 : return 30;
          default : return 3;
      }
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      static NSString *CellIdentifier = @"Cell";
  
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
      if (cell == nil) 
      {
          cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
      }
  
      // Configure the cell.
  
      switch (indexPath.row)
      {
          case 0 : cell.textLabel.text = @"First Cell"; break;
          case 1 : cell.textLabel.text = @"Second Cell"; break;
          case 2 : cell.textLabel.text = @"Third Cell"; break;
          case 3 : cell.textLabel.text = @"Fourth Cell"; break;
          case 4 : cell.textLabel.text = @"Fifth Cell"; break;
          case 5 : cell.textLabel.text = @"Sixth Cell"; break;
          case 6 : cell.textLabel.text = @"Seventh Cell"; break;
          case 7 : cell.textLabel.text = @"Eighth Cell"; break;
          default : cell.textLabel.text = [NSString stringWithFormat:@"Cell %i",indexPath.row + 1];
      }
  
      //cell.detailTextLabel.text = ...;
  
      return cell;
  }
  </code></pre>
  
  <p>which is working also fine an populating the sections...but my real requirement is to populate the sections with the objects from a core data entity. That means, I have to substitute the lines:</p>
  
  <pre><code>switch (section)
          {
              case 2 : return 3;
              case 3 : return 30;
              default : return 3;
          }
  </code></pre>
  
  <p>with other code lines in order to obtain the real number of rows in the sections.
  And following code lines:</p>
  
  <pre><code>switch (indexPath.row)
          {
              case 0 : cell.textLabel.text = @"First Cell"; break;
              case 1 : cell.textLabel.text = @"Second Cell"; break;
              case 2 : cell.textLabel.text = @"Third Cell"; break;
              case 3 : cell.textLabel.text = @"Fourth Cell"; break;
              case 4 : cell.textLabel.text = @"Fifth Cell"; break;
              case 5 : cell.textLabel.text = @"Sixth Cell"; break;
              case 6 : cell.textLabel.text = @"Seventh Cell"; break;
              case 7 : cell.textLabel.text = @"Eighth Cell"; break;
              default : cell.textLabel.text = [NSString stringWithFormat:@"Cell %i",indexPath.row + 1];
          }
  </code></pre>
  
  <p>to be substituted with other code lines to call the real objects attributes.</p>
  
  <p>I have already included in y project all core data stack and also a NSFetchedResultsController.
  The core data entity has two attributes: tdText, tdDate. 
  The fixed sections are related to the tdDate attribute. </p>