title: Why are tableview headers initWithCoder method is called on reused headers
body: <p>I have a tableview with headers</p>
  
  <p>now i registered the header's nib like this :</p>
  
  <pre><code>[tableView registerNib:[UINib nibWithNibName:[self layoutName] bundle:[NSBundle mainBundle]] forHeaderFooterViewReuseIdentifier:[self cellIdentifier]];
  </code></pre>
  
  <p>inside the tableview controller</p>
  
  <p>and this line </p>
  
  <pre><code>MyCustomHeader *header = (MyCustomHeader*)[tableView dequeueReusableHeaderFooterViewWithIdentifier:[self cellIdentifier]];
  </code></pre>
  
  <p>always returns a non empty cell</p>
  
  <p>the nib i gave into the table header, has several custom objects
  after the call to <code>dequeueReusableHeaderFooterViewWithReuseIdentifier</code></p>
  
  <p>the <code>initWithCoder</code> of the custom object seems to be called</p>
  
  <p>why is that, if the cell is supposed to be reused, and all the objects were already "set up previously "?</p>
  
  <p>EDIT open/close code</p>
  
  <pre><code>- (void)sectionHeaderView:(BaseSectionHeaderView *)sectionHeaderView sectionOpened:(NSInteger)sectionOpened {
      LogInfo(@"opening section:%ld",sectionOpened);
      if(self.openSection.openSectionHeaderView == sectionHeaderView){
       [self sectionHeaderView:sectionHeaderView sectionClosed:sectionOpened];
          LogInfo(@"this section is already open");
          return;
      }
      [_purchaseDataSource setSectionAtIndex:sectionOpened Open:YES];
  
      /*
       Create an array containing the index paths of the rows to insert: These correspond to the rows for each quotation in the current section.
      */
      NSInteger countOfRowsToInsert = 1;
      NSMutableArray *indexPathsToInsert = [[NSMutableArray alloc] init];
     for (NSInteger i = 0; i &lt; countOfRowsToInsert; i++) {
          [indexPathsToInsert addObject:[NSIndexPath indexPathForRow:i inSection:sectionOpened]];
      }
  
      /*
       Create an array containing the index paths of the rows to delete: These correspond to the rows for each quotation in the previously-open section, if there was one.
       */
      NSMutableArray *indexPathsToDelete = [[NSMutableArray alloc] init];
  
     if (self.openSection.openSectionHeaderView != nil) {
  
          [_purchaseDataSource setSectionAtIndex:self.openSection.openSectionIndex Open:NO];
         [_openSection.openSectionHeaderView toggleOpenWithUserAction:NO];
         NSInteger countOfRowsToDelete = [_purchaseInvoiceListTable.tableView numberOfRowsInSection:self.openSection.openSectionIndex];        for (NSInteger i = 0; i &lt; countOfRowsToDelete; i++) {
              [indexPathsToDelete addObject:[NSIndexPath indexPathForRow:i inSection:self.openSection.openSectionIndex]];
          }
  
     }
  
      // style the animation so that there's a smooth flow in either direction
      UITableViewRowAnimation insertAnimation;
      UITableViewRowAnimation deleteAnimation;
      if (self.openSection.openSectionHeaderView == nil || sectionOpened &lt; self.openSection.openSectionIndex) {
          insertAnimation = UITableViewRowAnimationTop;
          deleteAnimation = UITableViewRowAnimationBottom;
      }
      else {
          insertAnimation = UITableViewRowAnimationBottom;
          deleteAnimation = UITableViewRowAnimationTop;
      }
  
  
          // apply the updates
          [_purchaseInvoiceListTable.tableView beginUpdates];
          [_purchaseInvoiceListTable.tableView insertRowsAtIndexPaths:indexPathsToInsert withRowAnimation:insertAnimation];
          [_purchaseInvoiceListTable.tableView deleteRowsAtIndexPaths:indexPathsToDelete withRowAnimation:deleteAnimation];
          [_purchaseInvoiceListTable.tableView endUpdates];
  
      CGRect frame = sectionHeaderView.frame;
      LogInfo(@"frame: %@",[NSValue valueWithCGRect:frame]);
      [self scrollTableViewFromBottomAnimated:YES];
  
          //
          self.openSection.openSectionIndex = sectionOpened;
          self.openSection.openSectionHeaderView = sectionHeaderView;
      self.openSection.sectionHeight = [NSNumber numberWithFloat:sectionHeaderView.frame.size.height];
          LogInfo(@"sectionOpened:%ld",sectionOpened);
  
  
  
  
  
  }
  
  
  
  
  
  - (void)sectionHeaderView:(BaseSectionHeaderView *)sectionHeaderView sectionClosed:(NSInteger)sectionClosed {
  
      /*
       Create an array of the index paths of the rows in the section that was closed, then delete those rows from the table view.
       */
         [_purchaseDataSource setSectionAtIndex:sectionClosed Open:NO];
      NSInteger countOfRowsToDelete = [_purchaseInvoiceListTable.tableView numberOfRowsInSection:sectionClosed];
  
      if (countOfRowsToDelete &gt; 0) {
          NSMutableArray *indexPathsToDelete = [[NSMutableArray alloc] init];
          for (NSInteger i = 0; i &lt; countOfRowsToDelete; i++) {
              [indexPathsToDelete addObject:[NSIndexPath indexPathForRow:i inSection:sectionClosed]];
          }
          [_purchaseInvoiceListTable.tableView beginUpdates];
          [_purchaseInvoiceListTable.tableView deleteRowsAtIndexPaths:indexPathsToDelete withRowAnimation:UITableViewRowAnimationTop];
          [_purchaseInvoiceListTable.tableView endUpdates];
  
  
      }
  
      self.openSection.openSectionIndex = NSNotFound;
      self.openSection.openSectionHeaderView = nil;
      LogInfo(@"sectionClosed:%ld",sectionClosed);
  }
  
  
  
  - (void)toggleOpenWithUserAction:(BOOL)userAction {
  
      // toggle the disclosure button state
      self.selected = !self.selected;
  
      // if this was a user action, send the delegate the appropriate message
      if (userAction) {
          if (self.selected) {
              if ([self.delegate respondsToSelector:@selector(sectionHeaderView:sectionOpened:)]) {
                  [self.delegate sectionHeaderView:self sectionOpened:self.section];
              }
          }
          else {
  
              if ([self.delegate respondsToSelector:@selector(sectionHeaderView:sectionClosed:)]) {
                  [self.delegate sectionHeaderView:self sectionClosed:self.section];
              }
          }
      }
  
  }
  </code></pre>