Revert "Revert "Safeguards""

This commit is contained in:
Roman Efimov
2015-02-27 16:58:02 -08:00
parent 13844fd025
commit df53394eee

View File

@@ -169,6 +169,9 @@
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)sectionIndex
{
if (self.mutableSections.count <= sectionIndex) {
return 0;
}
return ((RETableViewSection *)[self.mutableSections objectAtIndex:sectionIndex]).items.count;
}
@@ -258,12 +261,18 @@
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)sectionIndex
{
if (self.mutableSections.count <= sectionIndex) {
return nil;
}
RETableViewSection *section = [self.mutableSections objectAtIndex:sectionIndex];
return section.headerTitle;
}
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)sectionIndex
{
if (self.mutableSections.count <= sectionIndex) {
return nil;
}
RETableViewSection *section = [self.mutableSections objectAtIndex:sectionIndex];
return section.footerTitle;
}
@@ -283,6 +292,9 @@
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
if (self.mutableSections.count <= indexPath.section) {
return NO;
}
RETableViewSection *section = [self.mutableSections objectAtIndex:indexPath.section];
RETableViewItem *item = [section.items objectAtIndex:indexPath.row];
return item.moveHandler != nil;
@@ -414,6 +426,9 @@
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)sectionIndex
{
if (self.mutableSections.count <= sectionIndex) {
return UITableViewAutomaticDimension;
}
RETableViewSection *section = [self.mutableSections objectAtIndex:sectionIndex];
if (section.headerHeight != RETableViewSectionHeaderHeightAutomatic) {
@@ -463,6 +478,9 @@
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)sectionIndex
{
if (self.mutableSections.count <= sectionIndex) {
return UITableViewAutomaticDimension;
}
RETableViewSection *section = [self.mutableSections objectAtIndex:sectionIndex];
if (section.footerHeight != RETableViewSectionFooterHeightAutomatic) {
@@ -514,16 +532,17 @@
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (self.mutableSections.count <= indexPath.section) {
return UITableViewAutomaticDimension;
}
RETableViewSection *section = [self.mutableSections objectAtIndex:indexPath.section];
id item = [section.items objectAtIndex:indexPath.row];
// Forward to UITableView delegate
//
IF_IOS7_OR_GREATER (
if ([self.delegate conformsToProtocol:@protocol(UITableViewDelegate)] && [self.delegate respondsToSelector:@selector(tableView:estimatedHeightForRowAtIndexPath:)])
return [self.delegate tableView:tableView estimatedHeightForRowAtIndexPath:indexPath];
);
if ([self.delegate conformsToProtocol:@protocol(UITableViewDelegate)] && [self.delegate respondsToSelector:@selector(tableView:estimatedHeightForRowAtIndexPath:)])
return [self.delegate tableView:tableView estimatedHeightForRowAtIndexPath:indexPath];
CGFloat height = [[self classForCellAtIndexPath:indexPath] heightWithItem:item tableViewManager:self];
@@ -534,6 +553,9 @@
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)sectionIndex
{
if (self.mutableSections.count <= sectionIndex) {
return nil;
}
RETableViewSection *section = [self.mutableSections objectAtIndex:sectionIndex];
// Forward to UITableView delegate
@@ -546,6 +568,9 @@
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)sectionIndex
{
if (self.mutableSections.count <= sectionIndex) {
return nil;
}
RETableViewSection *section = [self.mutableSections objectAtIndex:sectionIndex];
// Forward to UITableView delegate