title: How To create sections in UITbleViewCell with a single NSArray?
body: <p>As popular sections in <code>UITableViewCell</code> with a single <code>NSArray</code>?
  I have an array of events, load the data into <code>cellForRowAtIndexPath</code>, should I create sections by year event.
  <br/>
   example:
  <br/>
  <br/>
   <strong>section 2012</strong><br/>
   Date: 01/01/2012<br/>
   Event: Live Music<br/>
  <br/>
   Date: 01/02/2012<br/>
   Event: Live Music<br/>
  <br/>
   <strong>section 2011</strong><br/>
   Date: 01/01/2011<br/>
   Event: Live Music<br/>
  <br/>
   Date: 01/02/2011<br/>
   Event: Live Music<br/>
  <br/></p>
  
  <p>The cells are already populated, I miss only the division into sections, the sections to create two (max two Years).</p>
  
  <p>Sorry, I'm still a little confused, I can not solve, please help me, when test the year? I'll post my code, thanks a lot</p>
  
  <pre><code>-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
   {
      static NSString *CellIdentifier = @"Cell";
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
      if (cell == nil) {
          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
                //acquisisco la data dell'evento
          NSString *dataEv = [[events objectAtIndex:indexPath.row + indexPath.section]DataEvento];
  
  
  //retrive year ,example 2011, 2012 when test?
  NSString *Year = [Utility getPartOfDate:dataEv type:UTLGetYear];
      //set image
      ...
      [cell.contentView addSubview:myImg];
  
      //set day
      day.text = [Utility getPartOfDate:dataEv type:UTLGetNumberOfDay];;
      [cell.contentView addSubview:day];
  
      //set dayOfWeek
      ...
      dayOfWeek.text = [Utility getPartOfDate:dataEv type:UTLGetDayOfWeek];;
      [cell.contentView addSubview:dayOfWeek];
  
      //set month
      month.text = [Utility getPartOfDate:dataEv type:UTLGetTextMonth];;
      [cell.contentView addSubview:month];
  
      //set title
      ...
      lblTitleEvent.text = [[eventi objectAtIndex:indexPath.row + indexPath.section]Artist];
      [cell.contentView addSubview:lblTitoloEvento];
  
      //set description event
      lblDescEvento.text = [[eventi objectAtIndex:indexPath.row + indexPath.section]Description];
      [cell.contentView addSubview:lblDescriptionEvent];
  
  
        }else{
  
      lblTitleEvent = (UILabel*)[cell.contentView viewWithTag:5];
      lblTitleEvent.text = [[events objectAtIndex:indexPath.row + indexPath.section]Artista];
  
      lblDescEvent = (UILabel*)[cell.contentView viewWithTag:6];
      lblDescEvent.text = [[events objectAtIndex:indexPath.row + indexPath.section]Description];
  }
  
  return cell;
  </code></pre>
  
  <p>}</p>
  
  <pre><code>- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
      return 2;
  }
  
  
      // Customize the number of rows in the table view.
      - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
         return [events count];        
      }
  
      - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {        
              if(section == 0){
                  return @"Section 1";
              }
              if(section == 1){
                  return @"Section 2";
              }
          }
  </code></pre>