Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Classes/YLTableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ - (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style {

- (void)registerClass:(Class)cellClass forCellReuseIdentifier:(NSString *)identifier {
NSAssert(identifier, @"Must have a reuse identifier.");
NSAssert([cellClass conformsToProtocol:@protocol(YLTableViewCell)], @"You can only use cells conforming to YLTableViewCell.");

[super registerClass:cellClass forCellReuseIdentifier:identifier];

if (cellClass) {
NSAssert([cellClass conformsToProtocol:@protocol(YLTableViewCell)], @"You can only use cells conforming to YLTableViewCell.");

self.cellClassForReuseIdentifier[identifier] = cellClass;
} else {
[self.cellClassForReuseIdentifier removeObjectForKey:identifier];
Expand Down
10 changes: 10 additions & 0 deletions YLTableViewTests/YLTableViewDataSourceTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ - (void)testNonConformingCell {
XCTAssertThrows([self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"]);
}

- (void)testUnregistereredTableCell {
NSString *const kUnregisteredReuseIdentifier = @"UnregisteredClass-ReuseId";

[self.tableView registerClass:[YLTableViewCellTestStub class] forCellReuseIdentifier:kUnregisteredReuseIdentifier];
XCTAssertNotNil([self.tableView dequeueReusableCellWithIdentifier:kUnregisteredReuseIdentifier]);

[self.tableView registerClass:nil forCellReuseIdentifier:kUnregisteredReuseIdentifier];
XCTAssertNil([self.tableView dequeueReusableCellWithIdentifier:kUnregisteredReuseIdentifier]);
}

- (void)testEstimatedRowHeightOverride {
self.dataSource.shouldOverrideEstimatedRowHeight = YES;
CGFloat height = [self.dataSource tableView:self.tableView estimatedHeightForRowAtIndexPath:[self _indexPathForCustomReuseIdentifier]];
Expand Down