Dequeueing cells from UITableView that have xib files enabled

ios, ios7, uikit, uitableview

Solution

To load cells from a xib file, you have to register it with `registerNib:`, not with `registerClass:`. Example:

[self.fieldListTableView registerNib:[UINib nibWithNibName:@"MyCellClass" bundle:nil]
  forCellReuseIdentifier:@"MyCellIdentifier"];

Problem

In my UITableViewController subclass, I register my cell class as follows: `[[self fieldListTableView] registerClass:[MyCellClass class] forCellReuseIdentifier:@"MyCellIdentifier"];` I then dequeue the cell using the method introduced in iOS 6: `MyCellClass* cell = (MyCellClass *)[tableView dequeueReusableCellWithIdentifier:@"MyCellIdentifier" forIndexPath:indexPath];` However the cell's xib file seems to be missing. When I run `po cell` in lldb, I get a valid looking cell object. Then when I try `po [cell myLabelOutlet]`, I get a `nil` in response. Do I need to register the XIB file too?

Original source