Has anybody got this working with an xib file?
I tried this but it crashes on me:
Code:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
id <NSFetchedResultsSectionInfo> sectionInfo = [[fetchedResultsController sections]
objectAtIndex:section];
SpecialOffersTableViewSectionHeader *tableViewSectionHeader =
(SpecialOffersTableViewSectionHeader*)[[[NSBundle mainBundle] loadNibNamed:@"SpecialOffersTableViewSectionHeader"
owner:self
options:nil] lastObject];
tableViewSectionHeader.sectionHeader.text = [sectionInfo name];
self.tableView.tableHeaderView = tableViewSectionHeader;
return tableViewSectionHeader;
}
Code:
@interface SpecialOffersTableViewSectionHeader : UIView {
IBOutlet UILabel *sectionHeader;
}
@property (nonatomic, retain) IBOutlet UILabel *sectionHeader;
@end
Code:
#import "SpecialOffersTableViewSectionHeader.h"
@implementation SpecialOffersTableViewSectionHeader
@synthesize sectionHeader;
- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
// Initialization code
}
return self;
}
- (void)drawRect:(CGRect)rect {
// Drawing code
}
- (void)dealloc {
[super dealloc];
}
@end
The error I get in the console is:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<SpecialOffersTableViewController 0x3c0c8f0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key sectionHeader.'